Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions cmd/nvidia-ctk/cdi/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ type options struct {
ignorePatterns []string
}

noAllDevice bool

// the following are used for dependency injection during spec generation.
nvmllib nvml.Interface
}
Expand Down Expand Up @@ -232,6 +234,12 @@ func (m command) build() *cli.Command {
Destination: &opts.featureFlags,
Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_FEATURE_FLAGS"),
},
&cli.BoolFlag{
Name: "no-all-device",
Usage: "Don't generate an `all` device for the resultant spec",
Destination: &opts.noAllDevice,
Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_NO_ALL_DEVICE"),
},
},
}

Expand Down Expand Up @@ -387,13 +395,18 @@ func (m command) generateSpecs(opts *options) ([]generatedSpecs, error) {
spec.WithVendor(opts.vendor),
spec.WithEdits(*commonEdits.ContainerEdits),
spec.WithFormat(opts.format),
spec.WithMergedDeviceOptions(
transform.WithName(allDeviceName),
transform.WithSkipIfExists(true),
),
spec.WithPermissions(0644),
}

if !opts.noAllDevice {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the "no-all-device" is set the spec will be generated without the option of transform.WithName(allDeviceName)

commonSpecOptions = append(commonSpecOptions,
spec.WithMergedDeviceOptions(
transform.WithName(allDeviceName),
transform.WithSkipIfExists(true),
),
)
}

fullSpec, err := spec.New(
append(commonSpecOptions,
spec.WithClass(opts.class),
Expand Down