/
starlark_run_config.go
115 lines (97 loc) · 3.65 KB
/
starlark_run_config.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package starlark_run_config
import "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
const (
defaultRelativePathToMainFile = ""
defaultMainFunctionName = ""
defaultSerializedParams = "{}"
defaultDryRun = false
defaultParallelism = 4
defaultCloudInstanceId = ""
defaultCloudUserId = ""
defaultImageDownload = kurtosis_core_rpc_api_bindings.ImageDownloadMode_missing
defaultNonBlockingMode = false
)
var defaultExperimentalFeatureFlags = []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag(nil)
type StarlarkRunConfig struct {
RelativePathToMainFile string
MainFunctionName string
SerializedParams string
DryRun bool
Parallelism int32
ExperimentalFeatureFlags []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag
CloudInstanceId string
CloudUserId string
ImageDownload kurtosis_core_rpc_api_bindings.ImageDownloadMode
NonBlockingMode bool
}
type starlarkRunConfigOption func(*StarlarkRunConfig)
func NewRunStarlarkConfig(opts ...starlarkRunConfigOption) *StarlarkRunConfig {
config := &StarlarkRunConfig{
RelativePathToMainFile: defaultRelativePathToMainFile,
MainFunctionName: defaultMainFunctionName,
SerializedParams: defaultSerializedParams,
DryRun: defaultDryRun,
Parallelism: defaultParallelism,
ExperimentalFeatureFlags: defaultExperimentalFeatureFlags,
CloudInstanceId: defaultCloudInstanceId,
CloudUserId: defaultCloudUserId,
ImageDownload: defaultImageDownload,
NonBlockingMode: defaultNonBlockingMode,
}
for _, opt := range opts {
opt(config)
}
return config
}
func WithRelativePathToMainFile(relativePathToMainFile string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.RelativePathToMainFile = relativePathToMainFile
}
}
func WithMainFunctionName(mainFunctionName string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.MainFunctionName = mainFunctionName
}
}
func WithSerializedParams(serializedParams string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.SerializedParams = serializedParams
}
}
func WithDryRun(dryRun bool) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.DryRun = dryRun
}
}
func WithParallelism(parallelism int32) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.Parallelism = parallelism
}
}
func WithExperimentalFeatureFlags(experimentalFeatureFlags []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.ExperimentalFeatureFlags = experimentalFeatureFlags
}
}
// Deprecated: This isn't used anymore and the value passed will not be read anywhere
func WithCloudInstanceId(cloudInstanceId string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.CloudInstanceId = cloudInstanceId
}
}
// Deprecated: This isn't used anymore and the value passed will not be read anywhere
func WithCloudUserId(cloudUserId string) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.CloudUserId = cloudUserId
}
}
func WithImageDownloadMode(imageDownloadMode kurtosis_core_rpc_api_bindings.ImageDownloadMode) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.ImageDownload = imageDownloadMode
}
}
func WithNonBlockingMode(nonBlockingMode bool) starlarkRunConfigOption {
return func(config *StarlarkRunConfig) {
config.NonBlockingMode = nonBlockingMode
}
}