-
Notifications
You must be signed in to change notification settings - Fork 61
/
options.go
79 lines (69 loc) · 1.87 KB
/
options.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package target
import (
"kraftkit.sh/initrd"
"kraftkit.sh/kconfig"
"kraftkit.sh/unikraft/arch"
"kraftkit.sh/unikraft/plat"
)
// TargetOption is a function that modifies a TargetConfig.
type TargetOption func(*TargetConfig) error
// WithName sets the name of the target.
func WithName(name string) TargetOption {
return func(tc *TargetConfig) error {
tc.name = name
return nil
}
}
// WithVersion sets the version of the target.
func WithArchitecture(arch arch.Architecture) TargetOption {
return func(tc *TargetConfig) error {
tc.architecture = arch
return nil
}
}
// WithPlatform sets the platform of the target.
func WithPlatform(platform plat.Platform) TargetOption {
return func(tc *TargetConfig) error {
tc.platform = platform
return nil
}
}
// WithKConfig sets the kconfig of the target.
func WithKConfig(kconfig kconfig.KeyValueMap) TargetOption {
return func(tc *TargetConfig) error {
tc.kconfig = kconfig
return nil
}
}
// WithKernel sets the kernel of the target.
func WithKernel(kernel string) TargetOption {
return func(tc *TargetConfig) error {
tc.kernel = kernel
return nil
}
}
// WithKernelDbg sets the kernel debug of the target.
func WithKernelDbg(kernelDbg string) TargetOption {
return func(tc *TargetConfig) error {
tc.kernelDbg = kernelDbg
return nil
}
}
// WithInitrd sets the initrd of the target.
func WithInitrd(initrd initrd.Initrd) TargetOption {
return func(tc *TargetConfig) error {
tc.initrd = initrd
return nil
}
}
// WithCommand sets the command of the target.
func WithCommand(command []string) TargetOption {
return func(tc *TargetConfig) error {
tc.command = command
return nil
}
}