Skip to content

Commit 01077b4

Browse files
Add EnvVars option for all nvidia-ctk cdi commands
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 450f73a commit 01077b4

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,20 @@ func (m command) build() *cli.Command {
9696
Name: "config-search-path",
9797
Usage: "Specify the path to search for config files when discovering the entities that should be included in the CDI specification.",
9898
Destination: &opts.configSearchPaths,
99+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CONFIG_SEARCH_PATH"},
99100
},
100101
&cli.StringFlag{
101102
Name: "output",
102103
Usage: "Specify the file to output the generated CDI specification to. If this is '' the specification is output to STDOUT",
103104
Destination: &opts.output,
105+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_OUTPUT"},
104106
},
105107
&cli.StringFlag{
106108
Name: "format",
107109
Usage: "The output format for the generated spec [json | yaml]. This overrides the format defined by the output file extension (if specified).",
108110
Value: spec.FormatYAML,
109111
Destination: &opts.format,
112+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_FORMAT"},
110113
},
111114
&cli.StringFlag{
112115
Name: "mode",
@@ -116,27 +119,32 @@ func (m command) build() *cli.Command {
116119
"If mode is set to 'auto' the mode will be determined based on the system configuration.",
117120
Value: string(nvcdi.ModeAuto),
118121
Destination: &opts.mode,
122+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_MODE"},
119123
},
120124
&cli.StringFlag{
121125
Name: "dev-root",
122126
Usage: "Specify the root where `/dev` is located. If this is not specified, the driver-root is assumed.",
123127
Destination: &opts.devRoot,
128+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_DEV_ROOT"},
124129
},
125130
&cli.StringSliceFlag{
126131
Name: "device-name-strategy",
127132
Usage: "Specify the strategy for generating device names. If this is specified multiple times, the devices will be duplicated for each strategy. One of [index | uuid | type-index]",
128133
Value: cli.NewStringSlice(nvcdi.DeviceNameStrategyIndex, nvcdi.DeviceNameStrategyUUID),
129134
Destination: &opts.deviceNameStrategies,
135+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_DEVICE_NAME_STRATEGY"},
130136
},
131137
&cli.StringFlag{
132138
Name: "driver-root",
133139
Usage: "Specify the NVIDIA GPU driver root to use when discovering the entities that should be included in the CDI specification.",
134140
Destination: &opts.driverRoot,
141+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_DRIVER_ROOT"},
135142
},
136143
&cli.StringSliceFlag{
137144
Name: "library-search-path",
138145
Usage: "Specify the path to search for libraries when discovering the entities that should be included in the CDI specification.\n\tNote: This option only applies to CSV mode.",
139146
Destination: &opts.librarySearchPaths,
147+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_LIBRARY_SEARCH_PATH"},
140148
},
141149
&cli.StringFlag{
142150
Name: "nvidia-cdi-hook-path",
@@ -145,36 +153,42 @@ func (m command) build() *cli.Command {
145153
"If not specified, the PATH will be searched for `nvidia-cdi-hook`. " +
146154
"NOTE: That if this is specified as `nvidia-ctk`, the PATH will be searched for `nvidia-ctk` instead.",
147155
Destination: &opts.nvidiaCDIHookPath,
156+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_NVIDIA_CDI_HOOK_PATH"},
148157
},
149158
&cli.StringFlag{
150159
Name: "ldconfig-path",
151160
Usage: "Specify the path to use for ldconfig in the generated CDI specification",
152161
Destination: &opts.ldconfigPath,
162+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_LDCONFIG_PATH"},
153163
},
154164
&cli.StringFlag{
155165
Name: "vendor",
156166
Aliases: []string{"cdi-vendor"},
157167
Usage: "the vendor string to use for the generated CDI specification.",
158168
Value: "nvidia.com",
159169
Destination: &opts.vendor,
170+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_VENDOR"},
160171
},
161172
&cli.StringFlag{
162173
Name: "class",
163174
Aliases: []string{"cdi-class"},
164175
Usage: "the class string to use for the generated CDI specification.",
165176
Value: "gpu",
166177
Destination: &opts.class,
178+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CLASS"},
167179
},
168180
&cli.StringSliceFlag{
169181
Name: "csv.file",
170182
Usage: "The path to the list of CSV files to use when generating the CDI specification in CSV mode.",
171183
Value: cli.NewStringSlice(csv.DefaultFileList()...),
172184
Destination: &opts.csv.files,
185+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CSV_FILE"},
173186
},
174187
&cli.StringSliceFlag{
175188
Name: "csv.ignore-pattern",
176189
Usage: "Specify a pattern the CSV mount specifications.",
177190
Destination: &opts.csv.ignorePatterns,
191+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CSV_IGNORE_PATTERN"},
178192
},
179193
}
180194

cmd/nvidia-ctk/cdi/list/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (m command) build() *cli.Command {
6464
Usage: "specify the directories to scan for CDI specifications",
6565
Value: cli.NewStringSlice(cdi.DefaultSpecDirs...),
6666
Destination: &cfg.cdiSpecDirs,
67+
EnvVars: []string{"NVIDIA_CTK_CDI_LIST_SPEC_DIR"},
6768
},
6869
}
6970

cmd/nvidia-ctk/cdi/transform/root/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,34 @@ func (m command) build() *cli.Command {
7373
Name: "from",
7474
Usage: "specify the root to be transformed",
7575
Destination: &opts.from,
76+
EnvVars: []string{"NVIDIA_CTK_CDI_TRANSFORM_ROOT_FROM"},
7677
},
7778
&cli.StringFlag{
7879
Name: "input",
7980
Usage: "Specify the file to read the CDI specification from. If this is '-' the specification is read from STDIN",
8081
Value: "-",
8182
Destination: &opts.input,
83+
EnvVars: []string{"NVIDIA_CTK_CDI_TRANSFORM_ROOT_INPUT"},
8284
},
8385
&cli.StringFlag{
8486
Name: "output",
8587
Usage: "Specify the file to output the generated CDI specification to. If this is '' the specification is output to STDOUT",
8688
Destination: &opts.output,
89+
EnvVars: []string{"NVIDIA_CTK_CDI_TRANSFORM_ROOT_OUTPUT"},
8790
},
8891
&cli.StringFlag{
8992
Name: "relative-to",
9093
Usage: "specify whether the transform is relative to the host or to the container. One of [ host | container ]",
9194
Value: "host",
9295
Destination: &opts.relativeTo,
96+
EnvVars: []string{"NVIDIA_CTK_CDI_TRANSFORM_ROOT_RELATIVE_TO"},
9397
},
9498
&cli.StringFlag{
9599
Name: "to",
96100
Usage: "specify the replacement root. If this is the same as the from root, the transform is a no-op.",
97101
Value: "",
98102
Destination: &opts.to,
103+
EnvVars: []string{"NVIDIA_CTK_CDI_TRANSFORM_ROOT_TO"},
99104
},
100105
}
101106

0 commit comments

Comments
 (0)