options.go 1.09 KB
Newer Older
songlinfeng's avatar
songlinfeng committed
1
2
3
4
5
6
7
/**
# Copyright (c) 2024, HCUOpt CORPORATION.  All rights reserved.
**/

package dhcu

import (
8
9
	"dcu-container-toolkit/internal/c3000caps"
	"dcu-container-toolkit/internal/logger"
songlinfeng's avatar
songlinfeng committed
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
)

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
	}
}