Skip to content

Commit 28add0a

Browse files
Merge pull request #1123 from ArangoGutierrez/cdi_generate_env_cli
Add EnvVars option for all nvidia-ctk cdi commands
2 parents b55255e + ce3e2c1 commit 28add0a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,20 @@ func (m command) build() *cli.Command {
9797
Name: "config-search-path",
9898
Usage: "Specify the path to search for config files when discovering the entities that should be included in the CDI specification.",
9999
Destination: &opts.configSearchPaths,
100+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CONFIG_SEARCH_PATHS"},
100101
},
101102
&cli.StringFlag{
102103
Name: "output",
103104
Usage: "Specify the file to output the generated CDI specification to. If this is '' the specification is output to STDOUT",
104105
Destination: &opts.output,
106+
EnvVars: []string{"NVIDIA_CTK_CDI_OUTPUT_FILE_PATH"},
105107
},
106108
&cli.StringFlag{
107109
Name: "format",
108110
Usage: "The output format for the generated spec [json | yaml]. This overrides the format defined by the output file extension (if specified).",
109111
Value: spec.FormatYAML,
110112
Destination: &opts.format,
113+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_OUTPUT_FORMAT"},
111114
},
112115
&cli.StringFlag{
113116
Name: "mode",
@@ -117,27 +120,32 @@ func (m command) build() *cli.Command {
117120
"If mode is set to 'auto' the mode will be determined based on the system configuration.",
118121
Value: string(nvcdi.ModeAuto),
119122
Destination: &opts.mode,
123+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_MODE"},
120124
},
121125
&cli.StringFlag{
122126
Name: "dev-root",
123127
Usage: "Specify the root where `/dev` is located. If this is not specified, the driver-root is assumed.",
124128
Destination: &opts.devRoot,
129+
EnvVars: []string{"NVIDIA_CTK_DEV_ROOT"},
125130
},
126131
&cli.StringSliceFlag{
127132
Name: "device-name-strategy",
128133
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]",
129134
Value: cli.NewStringSlice(nvcdi.DeviceNameStrategyIndex, nvcdi.DeviceNameStrategyUUID),
130135
Destination: &opts.deviceNameStrategies,
136+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_DEVICE_NAME_STRATEGIES"},
131137
},
132138
&cli.StringFlag{
133139
Name: "driver-root",
134140
Usage: "Specify the NVIDIA GPU driver root to use when discovering the entities that should be included in the CDI specification.",
135141
Destination: &opts.driverRoot,
142+
EnvVars: []string{"NVIDIA_CTK_DRIVER_ROOT"},
136143
},
137144
&cli.StringSliceFlag{
138145
Name: "library-search-path",
139146
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.",
140147
Destination: &opts.librarySearchPaths,
148+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_LIBRARY_SEARCH_PATHS"},
141149
},
142150
&cli.StringFlag{
143151
Name: "nvidia-cdi-hook-path",
@@ -146,36 +154,42 @@ func (m command) build() *cli.Command {
146154
"If not specified, the PATH will be searched for `nvidia-cdi-hook`. " +
147155
"NOTE: That if this is specified as `nvidia-ctk`, the PATH will be searched for `nvidia-ctk` instead.",
148156
Destination: &opts.nvidiaCDIHookPath,
157+
EnvVars: []string{"NVIDIA_CTK_CDI_HOOK_PATH"},
149158
},
150159
&cli.StringFlag{
151160
Name: "ldconfig-path",
152161
Usage: "Specify the path to use for ldconfig in the generated CDI specification",
153162
Destination: &opts.ldconfigPath,
163+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_LDCONFIG_PATH"},
154164
},
155165
&cli.StringFlag{
156166
Name: "vendor",
157167
Aliases: []string{"cdi-vendor"},
158168
Usage: "the vendor string to use for the generated CDI specification.",
159169
Value: "nvidia.com",
160170
Destination: &opts.vendor,
171+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_VENDOR"},
161172
},
162173
&cli.StringFlag{
163174
Name: "class",
164175
Aliases: []string{"cdi-class"},
165176
Usage: "the class string to use for the generated CDI specification.",
166177
Value: "gpu",
167178
Destination: &opts.class,
179+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CLASS"},
168180
},
169181
&cli.StringSliceFlag{
170182
Name: "csv.file",
171183
Usage: "The path to the list of CSV files to use when generating the CDI specification in CSV mode.",
172184
Value: cli.NewStringSlice(csv.DefaultFileList()...),
173185
Destination: &opts.csv.files,
186+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CSV_FILES"},
174187
},
175188
&cli.StringSliceFlag{
176189
Name: "csv.ignore-pattern",
177190
Usage: "specify a pattern the CSV mount specifications.",
178191
Destination: &opts.csv.ignorePatterns,
192+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_CSV_IGNORE_PATTERNS"},
179193
},
180194
&cli.StringSliceFlag{
181195
Name: "disable-hook",
@@ -185,6 +199,7 @@ func (m command) build() *cli.Command {
185199
"special hook name 'all' can be used ensure that the generated " +
186200
"CDI specification does not include any hooks.",
187201
Destination: &opts.disabledHooks,
202+
EnvVars: []string{"NVIDIA_CTK_CDI_GENERATE_DISABLED_HOOKS"},
188203
},
189204
}
190205

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_SPEC_DIRS"},
6768
},
6869
}
6970

0 commit comments

Comments
 (0)