options.go 1.09 KB
Newer Older
songlinfeng's avatar
songlinfeng committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
# Copyright (c) 2024, HCUOpt CORPORATION.  All rights reserved.
**/

package dhcu

import (
	"dtk-container-toolkit/internal/c3000caps"
	"dtk-container-toolkit/internal/logger"
)

type options struct {
	logger         logger.Interface
	devRoot        string
	dtkCDIHookPath string

	isMigDevice bool
	// migCaps stores the MIG capabilities for the system.
	// If MIG is not available, this is nil.
	migCaps      c3000caps.MigCaps
	migCapsError error
}

type Option func(*options)

// WithDevRoot sets the root where /dev is located.
func WithDevRoot(root string) Option {
	return func(l *options) {
		l.devRoot = root
	}
}

// WithLogger sets the logger for the library
func WithLogger(logger logger.Interface) Option {
	return func(l *options) {
		l.logger = logger
	}
}

// WithDTKCDIHookPath sets the path to the DTK Container Toolkit CLI path for the library
func WithDTKCDIHookPath(path string) Option {
	return func(l *options) {
		l.dtkCDIHookPath = path
	}
}

// WithMIGCaps sets the MIG capabilities.
func WithMIGCaps(migCaps c3000caps.MigCaps) Option {
	return func(l *options) {
		l.migCaps = migCaps
	}
}