mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Add --cdi-enabled option to control generating CDI spec
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -56,6 +56,7 @@ type options struct {
|
||||
ContainerCLIDebug string
|
||||
toolkitRoot string
|
||||
|
||||
cdiEnabled bool
|
||||
cdiOutputDir string
|
||||
cdiKind string
|
||||
cdiVendor string
|
||||
@@ -171,6 +172,13 @@ func main() {
|
||||
Destination: &opts.toolkitRoot,
|
||||
EnvVars: []string{"TOOLKIT_ROOT"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "cdi-enabled",
|
||||
Aliases: []string{"enable-cdi"},
|
||||
Usage: "enable the generation of a CDI specification",
|
||||
Destination: &opts.cdiEnabled,
|
||||
EnvVars: []string{"CDI_ENABLED", "ENABLE_CDI"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "cdi-output-dir",
|
||||
Usage: "the directory where the CDI output files are to be written. If this is set to '', no CDI specification is generated.",
|
||||
@@ -592,6 +600,9 @@ func createDirectories(dir ...string) error {
|
||||
|
||||
// generateCDISpec generates a CDI spec for use in managemnt containers
|
||||
func generateCDISpec(opts *options, nvidiaCTKPath string) error {
|
||||
if !opts.cdiEnabled {
|
||||
return nil
|
||||
}
|
||||
if opts.cdiOutputDir == "" {
|
||||
log.Info("Skipping CDI spec generation (no output directory specified)")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user