mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Remove target-driver-root from generate
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
6a83e2ebe5
commit
f27c33b45f
@ -26,7 +26,6 @@ import (
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/edits"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform"
|
||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||
specs "github.com/container-orchestrated-devices/container-device-interface/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -46,10 +45,8 @@ type config struct {
|
||||
format string
|
||||
deviceNameStrategy string
|
||||
driverRoot string
|
||||
targetDriverRoot string
|
||||
nvidiaCTKPath string
|
||||
mode string
|
||||
kind string
|
||||
vendor string
|
||||
class string
|
||||
}
|
||||
@ -114,17 +111,18 @@ func (m command) build() *cli.Command {
|
||||
Destination: &cfg.nvidiaCTKPath,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "target-driver-root",
|
||||
Usage: "Specify the NVIDIA GPU driver root to use in the generated CDI specification. Only used if not empty and differs from 'driver-root' used during discovery.",
|
||||
Value: "",
|
||||
Destination: &cfg.targetDriverRoot,
|
||||
Name: "vendor",
|
||||
Aliases: []string{"cdi-vendor"},
|
||||
Usage: "the vendor string to use for the generated CDI specification.",
|
||||
Value: "nvidia.com",
|
||||
Destination: &cfg.vendor,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "kind",
|
||||
Aliases: []string{"cdi-kind"},
|
||||
Usage: "the vendor string to use for the generated CDI specification.",
|
||||
Value: "nvidia.com/gpu",
|
||||
Destination: &cfg.kind,
|
||||
Name: "class",
|
||||
Aliases: []string{"cdi-class"},
|
||||
Usage: "the class string to use for the generated CDI specification.",
|
||||
Value: "gpu",
|
||||
Destination: &cfg.class,
|
||||
},
|
||||
}
|
||||
|
||||
@ -158,10 +156,6 @@ func (m command) validateFlags(c *cli.Context, cfg *config) error {
|
||||
|
||||
cfg.nvidiaCTKPath = discover.FindNvidiaCTK(m.logger, cfg.nvidiaCTKPath)
|
||||
|
||||
if cfg.targetDriverRoot == "" {
|
||||
cfg.targetDriverRoot = cfg.driverRoot
|
||||
}
|
||||
|
||||
if outputFileFormat := formatFromFilename(cfg.output); outputFileFormat != "" {
|
||||
m.logger.Debugf("Inferred output format as %q from output file name", outputFileFormat)
|
||||
if !c.IsSet("format") {
|
||||
@ -171,16 +165,12 @@ func (m command) validateFlags(c *cli.Context, cfg *config) error {
|
||||
}
|
||||
}
|
||||
|
||||
vendor, class := cdi.ParseQualifier(cfg.kind)
|
||||
if err := cdi.ValidateVendorName(vendor); err != nil {
|
||||
if err := cdi.ValidateVendorName(cfg.vendor); err != nil {
|
||||
return fmt.Errorf("invalid CDI vendor name: %v", err)
|
||||
}
|
||||
if err := cdi.ValidateClassName(class); err != nil {
|
||||
if err := cdi.ValidateClassName(cfg.class); err != nil {
|
||||
return fmt.Errorf("invalid CDI class name: %v", err)
|
||||
}
|
||||
cfg.vendor = vendor
|
||||
cfg.class = class
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -255,26 +245,13 @@ func (m command) generateSpec(cfg *config) (spec.Interface, error) {
|
||||
return nil, fmt.Errorf("failed to create edits common for entities: %v", err)
|
||||
}
|
||||
|
||||
spec, err := spec.New(
|
||||
return spec.New(
|
||||
spec.WithVendor(cfg.vendor),
|
||||
spec.WithClass(cfg.class),
|
||||
spec.WithDeviceSpecs(deviceSpecs),
|
||||
spec.WithEdits(*commonEdits.ContainerEdits),
|
||||
spec.WithFormat(cfg.format),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = transform.NewRootTransformer(
|
||||
cfg.driverRoot,
|
||||
cfg.targetDriverRoot,
|
||||
).Transform(spec.Raw())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to transform driver root in CDI spec: %v", err)
|
||||
}
|
||||
|
||||
return spec, err
|
||||
}
|
||||
|
||||
// MergeDeviceSpecs creates a device with the specified name which combines the edits from the previous devices.
|
||||
|
Loading…
Reference in New Issue
Block a user