Skip to content

Commit 0353955

Browse files
committed
Replace EnvVars with Sources cli.EnvVars
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent face5ba commit 0353955

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed

cmd/config-manager/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,76 +130,76 @@ func main() {
130130
Value: DefaultOneshot,
131131
Usage: "check and update the config only once and then exit",
132132
Destination: &flags.Oneshot,
133-
EnvVars: []string{"ONESHOT"},
133+
Sources: cli.EnvVars("ONESHOT"),
134134
},
135135
&cli.StringFlag{
136136
Name: "kubeconfig",
137137
Value: "",
138138
Usage: "absolute path to the kubeconfig file",
139139
Destination: &flags.Kubeconfig,
140-
EnvVars: []string{"KUBECONFIG"},
140+
Sources: cli.EnvVars("KUBECONFIG"),
141141
},
142142
&cli.StringFlag{
143143
Name: "node-name",
144144
Value: "",
145145
Usage: "the name of the node to watch for label changes on",
146146
Destination: &flags.NodeName,
147-
EnvVars: []string{"NODE_NAME"},
147+
Sources: cli.EnvVars("NODE_NAME"),
148148
},
149149
&cli.StringFlag{
150150
Name: "node-label",
151151
Value: DefaultConfigLabel,
152152
Usage: "the name of the node label to use for selecting a config",
153153
Destination: &flags.NodeLabel,
154-
EnvVars: []string{"NODE_LABEL"},
154+
Sources: cli.EnvVars("NODE_LABEL"),
155155
},
156156
&cli.StringFlag{
157157
Name: "config-file-srcdir",
158158
Value: "",
159159
Usage: "the path to the directory containing available device configuration files",
160160
Destination: &flags.ConfigFileSrcdir,
161-
EnvVars: []string{"CONFIG_FILE_SRCDIR"},
161+
Sources: cli.EnvVars("CONFIG_FILE_SRCDIR"),
162162
},
163163
&cli.StringFlag{
164164
Name: "config-file-dst",
165165
Value: "",
166166
Usage: "the path to destination device configuration file",
167167
Destination: &flags.ConfigFileDst,
168-
EnvVars: []string{"CONFIG_FILE_DST"},
168+
Sources: cli.EnvVars("CONFIG_FILE_DST"),
169169
},
170170
&cli.StringFlag{
171171
Name: "default-config",
172172
Value: "",
173173
Usage: "the default config to use if no label is set",
174174
Destination: &flags.DefaultConfig,
175-
EnvVars: []string{"DEFAULT_CONFIG"},
175+
Sources: cli.EnvVars("DEFAULT_CONFIG"),
176176
},
177177
&cli.StringSliceFlag{
178178
Name: "fallback-strategies",
179179
Usage: "ordered list of fallback strategies to use to set a default config when none is provided",
180180
Destination: &flags.FallbackStrategies,
181-
EnvVars: []string{"FALLBACK_STRATEGIES"},
181+
Sources: cli.EnvVars("FALLBACK_STRATEGIES"),
182182
},
183183
&cli.BoolFlag{
184184
Name: "send-signal",
185185
Value: DefaultSendSignal,
186186
Usage: "send a signal to <process-to-signal> once a config change is made",
187187
Destination: &flags.SendSignal,
188-
EnvVars: []string{"SEND_SIGNAL"},
188+
Sources: cli.EnvVars("SEND_SIGNAL"),
189189
},
190190
&cli.IntFlag{
191191
Name: "signal",
192192
Value: DefaultSignal,
193193
Usage: "the signal to sent to <process-to-signal> if <send-signal> is set",
194194
Destination: &flags.Signal,
195-
EnvVars: []string{"SIGNAL"},
195+
Sources: cli.EnvVars("SIGNAL"),
196196
},
197197
&cli.StringFlag{
198198
Name: "process-to-signal",
199199
Value: DefaultProcessToSignal,
200200
Usage: "the name of the process to signal if <send-signal> is set",
201201
Destination: &flags.ProcessToSignal,
202-
EnvVars: []string{"PROCESS_TO_SIGNAL"},
202+
Sources: cli.EnvVars("PROCESS_TO_SIGNAL"),
203203
},
204204
}
205205

cmd/gpu-feature-discovery/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,67 +53,67 @@ func main() {
5353
Name: "mig-strategy",
5454
Value: spec.MigStrategyNone,
5555
Usage: "the desired strategy for exposing MIG devices on GPUs that support it:\n\t\t[none | single | mixed]",
56-
EnvVars: []string{"GFD_MIG_STRATEGY", "MIG_STRATEGY"},
56+
Sources: cli.EnvVars("GFD_MIG_STRATEGY", "MIG_STRATEGY"),
5757
},
5858
&cli.BoolFlag{
5959
Name: "fail-on-init-error",
6060
Value: true,
6161
Usage: "fail the plugin if an error is encountered during initialization, otherwise block indefinitely",
62-
EnvVars: []string{"GFD_FAIL_ON_INIT_ERROR", "FAIL_ON_INIT_ERROR"},
62+
Sources: cli.EnvVars("GFD_FAIL_ON_INIT_ERROR", "FAIL_ON_INIT_ERROR"),
6363
},
6464
&cli.BoolFlag{
6565
Name: "oneshot",
6666
Value: false,
6767
Usage: "Label once and exit",
68-
EnvVars: []string{"GFD_ONESHOT"},
68+
Sources: cli.EnvVars("GFD_ONESHOT"),
6969
},
7070
&cli.BoolFlag{
7171
Name: "no-timestamp",
7272
Value: false,
7373
Usage: "Do not add the timestamp to the labels",
74-
EnvVars: []string{"GFD_NO_TIMESTAMP"},
74+
Sources: cli.EnvVars("GFD_NO_TIMESTAMP"),
7575
},
7676
&cli.DurationFlag{
7777
Name: "sleep-interval",
7878
Value: 60 * time.Second,
7979
Usage: "Time to sleep between labeling",
80-
EnvVars: []string{"GFD_SLEEP_INTERVAL"},
80+
Sources: cli.EnvVars("GFD_SLEEP_INTERVAL"),
8181
},
8282
&cli.StringFlag{
8383
Name: "output-file",
8484
Aliases: []string{"output", "o"},
8585
Value: "/etc/kubernetes/node-feature-discovery/features.d/gfd",
86-
EnvVars: []string{"GFD_OUTPUT_FILE"},
86+
Sources: cli.EnvVars("GFD_OUTPUT_FILE"),
8787
},
8888
&cli.StringFlag{
8989
Name: "machine-type-file",
9090
Value: "/sys/class/dmi/id/product_name",
9191
Usage: "a path to a file that contains the DMI (SMBIOS) information for the node",
92-
EnvVars: []string{"GFD_MACHINE_TYPE_FILE"},
92+
Sources: cli.EnvVars("GFD_MACHINE_TYPE_FILE"),
9393
},
9494
&cli.StringFlag{
9595
Name: "config-file",
9696
Usage: "the path to a config file as an alternative to command line options or environment variables",
9797
Destination: &config.configFile,
98-
EnvVars: []string{"GFD_CONFIG_FILE", "CONFIG_FILE"},
98+
Sources: cli.EnvVars("GFD_CONFIG_FILE", "CONFIG_FILE"),
9999
},
100100
&cli.BoolFlag{
101101
Name: "use-node-feature-api",
102102
Usage: "Use NFD NodeFeature API to publish labels",
103-
EnvVars: []string{"GFD_USE_NODE_FEATURE_API", "USE_NODE_FEATURE_API"},
103+
Sources: cli.EnvVars("GFD_USE_NODE_FEATURE_API", "USE_NODE_FEATURE_API"),
104104
},
105105
&cli.StringFlag{
106106
Name: "device-discovery-strategy",
107107
Value: "auto",
108108
Usage: "the strategy to use to discover devices: 'auto', 'nvml', 'tegra' or 'vfio'",
109-
EnvVars: []string{"DEVICE_DISCOVERY_STRATEGY"},
109+
Sources: cli.EnvVars("DEVICE_DISCOVERY_STRATEGY"),
110110
},
111111
&cli.StringFlag{
112112
Name: "driver-root-ctr-path",
113113
Aliases: []string{"container-driver-root"},
114114
Value: spec.DefaultContainerDriverRoot,
115115
Usage: "the path where the NVIDIA driver root is mounted in the container",
116-
EnvVars: []string{"DRIVER_ROOT_CTR_PATH", "CONTAINER_DRIVER_ROOT"},
116+
Sources: cli.EnvVars("DRIVER_ROOT_CTR_PATH", "CONTAINER_DRIVER_ROOT"),
117117
},
118118
}
119119

cmd/mps-control-daemon/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ func main() {
6666
Name: "config-file",
6767
Usage: "the path to a config file as an alternative to command line options or environment variables",
6868
Destination: &config.configFile,
69-
EnvVars: []string{"CONFIG_FILE"},
69+
Sources: cli.EnvVars("CONFIG_FILE"),
7070
},
7171
&cli.StringFlag{
7272
Name: "mig-strategy",
7373
Value: spec.MigStrategyNone,
7474
Usage: "the desired strategy for exposing MIG devices on GPUs that support it:\n\t\t[none | single | mixed]",
75-
EnvVars: []string{"MIG_STRATEGY"},
75+
Sources: cli.EnvVars("MIG_STRATEGY"),
7676
},
7777
}
7878
c.Flags = config.flags

cmd/nvidia-device-plugin/main.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,113 +61,113 @@ func main() {
6161
Name: "mig-strategy",
6262
Value: spec.MigStrategyNone,
6363
Usage: "the desired strategy for exposing MIG devices on GPUs that support it:\n\t\t[none | single | mixed]",
64-
EnvVars: []string{"MIG_STRATEGY"},
64+
Sources: cli.EnvVars("MIG_STRATEGY"),
6565
},
6666
&cli.BoolFlag{
6767
Name: "fail-on-init-error",
6868
Value: true,
6969
Usage: "fail the plugin if an error is encountered during initialization, otherwise block indefinitely",
70-
EnvVars: []string{"FAIL_ON_INIT_ERROR"},
70+
Sources: cli.EnvVars("FAIL_ON_INIT_ERROR"),
7171
},
7272
&cli.StringFlag{
7373
Name: "driver-root",
7474
Aliases: []string{"nvidia-driver-root"},
7575
Value: "/",
7676
Usage: "the root path for the NVIDIA driver installation on the host (typical values are '/' or '/run/nvidia/driver')",
77-
EnvVars: []string{"NVIDIA_DRIVER_ROOT"},
77+
Sources: cli.EnvVars("NVIDIA_DRIVER_ROOT"),
7878
},
7979
&cli.StringFlag{
8080
Name: "dev-root",
8181
Aliases: []string{"nvidia-dev-root"},
8282
Usage: "the root path for the NVIDIA device nodes on the host (typical values are '/' or '/run/nvidia/driver')",
83-
EnvVars: []string{"NVIDIA_DEV_ROOT"},
83+
Sources: cli.EnvVars("NVIDIA_DEV_ROOT"),
8484
},
8585
&cli.BoolFlag{
8686
Name: "pass-device-specs",
8787
Value: false,
8888
Usage: "pass the list of DeviceSpecs to the kubelet on Allocate()",
89-
EnvVars: []string{"PASS_DEVICE_SPECS"},
89+
Sources: cli.EnvVars("PASS_DEVICE_SPECS"),
9090
},
9191
&cli.StringSliceFlag{
9292
Name: "device-list-strategy",
9393
Value: cli.NewStringSlice(string(spec.DeviceListStrategyEnvVar)),
9494
Usage: "the desired strategy for passing the device list to the underlying runtime:\n\t\t[envvar | volume-mounts | cdi-annotations]",
95-
EnvVars: []string{"DEVICE_LIST_STRATEGY"},
95+
Sources: cli.EnvVars("DEVICE_LIST_STRATEGY"),
9696
},
9797
&cli.StringFlag{
9898
Name: "device-id-strategy",
9999
Value: spec.DeviceIDStrategyUUID,
100100
Usage: "the desired strategy for passing device IDs to the underlying runtime:\n\t\t[uuid | index]",
101-
EnvVars: []string{"DEVICE_ID_STRATEGY"},
101+
Sources: cli.EnvVars("DEVICE_ID_STRATEGY"),
102102
},
103103
&cli.BoolFlag{
104104
Name: "gdrcopy-enabled",
105105
Usage: "ensure that containers that request NVIDIA GPU resources are started with GDRCopy support",
106-
EnvVars: []string{"GDRCOPY_ENABLED"},
106+
Sources: cli.EnvVars("GDRCOPY_ENABLED"),
107107
},
108108
&cli.BoolFlag{
109109
Name: "gds-enabled",
110110
Usage: "ensure that containers that request NVIDIA GPU resources are started with GPUDirect Storage support",
111-
EnvVars: []string{"GDS_ENABLED"},
111+
Sources: cli.EnvVars("GDS_ENABLED"),
112112
},
113113
&cli.BoolFlag{
114114
Name: "mofed-enabled",
115115
Usage: "ensure that containers that request NVIDIA GPU resources are started with MOFED support",
116-
EnvVars: []string{"MOFED_ENABLED"},
116+
Sources: cli.EnvVars("MOFED_ENABLED"),
117117
},
118118
&cli.StringFlag{
119119
Name: "kubelet-socket",
120120
Value: pluginapi.KubeletSocket,
121121
Usage: "specify the socket for communicating with the kubelet; if this is empty, no connection with the kubelet is attempted",
122122
Destination: &o.kubeletSocket,
123-
EnvVars: []string{"KUBELET_SOCKET"},
123+
Sources: cli.EnvVars("KUBELET_SOCKET"),
124124
},
125125
&cli.StringFlag{
126126
Name: "config-file",
127127
Usage: "the path to a config file as an alternative to command line options or environment variables",
128128
Destination: &o.configFile,
129-
EnvVars: []string{"CONFIG_FILE"},
129+
Sources: cli.EnvVars("CONFIG_FILE"),
130130
},
131131
&cli.StringFlag{
132132
Name: "cdi-annotation-prefix",
133133
Value: spec.DefaultCDIAnnotationPrefix,
134134
Usage: "the prefix to use for CDI container annotation keys",
135-
EnvVars: []string{"CDI_ANNOTATION_PREFIX"},
135+
Sources: cli.EnvVars("CDI_ANNOTATION_PREFIX"),
136136
},
137137
&cli.StringFlag{
138138
Name: "nvidia-cdi-hook-path",
139139
Aliases: []string{"nvidia-ctk-path"},
140140
Value: spec.DefaultNvidiaCTKPath,
141141
Usage: "the path to use for NVIDIA CDI hooks in the generated CDI specification",
142-
EnvVars: []string{"NVIDIA_CDI_HOOK_PATH", "NVIDIA_CTK_PATH"},
142+
Sources: cli.EnvVars("NVIDIA_CDI_HOOK_PATH", "NVIDIA_CTK_PATH"),
143143
},
144144
&cli.StringFlag{
145145
Name: "driver-root-ctr-path",
146146
Aliases: []string{"container-driver-root"},
147147
Value: spec.DefaultContainerDriverRoot,
148148
Usage: "the path where the NVIDIA driver root is mounted in the container; used for generating CDI specifications",
149-
EnvVars: []string{"DRIVER_ROOT_CTR_PATH", "CONTAINER_DRIVER_ROOT"},
149+
Sources: cli.EnvVars("DRIVER_ROOT_CTR_PATH", "CONTAINER_DRIVER_ROOT"),
150150
},
151151
&cli.StringFlag{
152152
Name: "mps-root",
153153
Usage: "the path on the host where MPS-specific mounts and files are created by the MPS control daemon manager",
154-
EnvVars: []string{"MPS_ROOT"},
154+
Sources: cli.EnvVars("MPS_ROOT"),
155155
},
156156
&cli.StringFlag{
157157
Name: "device-discovery-strategy",
158158
Value: "auto",
159159
Usage: "the strategy to use to discover devices: 'auto', 'nvml', or 'tegra'",
160-
EnvVars: []string{"DEVICE_DISCOVERY_STRATEGY"},
160+
Sources: cli.EnvVars("DEVICE_DISCOVERY_STRATEGY"),
161161
},
162162
&cli.IntSliceFlag{
163163
Name: "imex-channel-ids",
164164
Usage: "A list of IMEX channels to inject.",
165-
EnvVars: []string{"IMEX_CHANNEL_IDS"},
165+
Sources: cli.EnvVars("IMEX_CHANNEL_IDS"),
166166
},
167167
&cli.BoolFlag{
168168
Name: "imex-required",
169169
Usage: "The specified IMEX channels are required",
170-
EnvVars: []string{"IMEX_REQUIRED"},
170+
Sources: cli.EnvVars("IMEX_REQUIRED"),
171171
},
172172
}
173173
o.flags = c.Flags

internal/flags/kubeclient.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ func (k *KubeClientConfig) Flags() []cli.Flag {
4646
Name: "kubeconfig",
4747
Usage: "Absolute path to the `KUBECONFIG` file. Either this flag or the KUBECONFIG env variable need to be set if the driver is being run out of cluster.",
4848
Destination: &k.KubeConfig,
49-
EnvVars: []string{"KUBECONFIG"},
49+
Sources: cli.EnvVars("KUBECONFIG"),
5050
},
5151
&cli.Float64Flag{
5252
Category: "Kubernetes client:",
5353
Name: "kube-api-qps",
5454
Usage: "`QPS` to use while communicating with the Kubernetes apiserver.",
5555
Value: 5,
5656
Destination: &k.KubeAPIQPS,
57-
EnvVars: []string{"KUBE_API_QPS"},
57+
Sources: cli.EnvVars("KUBE_API_QPS"),
5858
},
5959
&cli.IntFlag{
6060
Category: "Kubernetes client:",
6161
Name: "kube-api-burst",
6262
Usage: "`Burst` to use while communicating with the Kubernetes apiserver.",
6363
Value: 10,
6464
Destination: &k.KubeAPIBurst,
65-
EnvVars: []string{"KUBE_API_BURST"},
65+
Sources: cli.EnvVars("KUBE_API_BURST"),
6666
},
6767
}
6868

internal/flags/node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ func (n *NodeConfig) Flags() []cli.Flag {
3333
Usage: "The namespace used for the custom resources.",
3434
Value: "default",
3535
Destination: &n.Namespace,
36-
EnvVars: []string{"NAMESPACE"},
36+
Sources: cli.EnvVars("NAMESPACE"),
3737
},
3838
&cli.StringFlag{
3939
Name: "node-name",
4040
Usage: "The name of the node to be worked on.",
4141
Destination: &n.Name,
42-
EnvVars: []string{"NODE_NAME"},
42+
Sources: cli.EnvVars("NODE_NAME"),
4343
},
4444
}
4545
return flags

0 commit comments

Comments
 (0)