mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-02-16 17:42:20 +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/internal/edits"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi"
|
"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/spec"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform"
|
|
||||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||||
specs "github.com/container-orchestrated-devices/container-device-interface/specs-go"
|
specs "github.com/container-orchestrated-devices/container-device-interface/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -46,10 +45,8 @@ type config struct {
|
|||||||
format string
|
format string
|
||||||
deviceNameStrategy string
|
deviceNameStrategy string
|
||||||
driverRoot string
|
driverRoot string
|
||||||
targetDriverRoot string
|
|
||||||
nvidiaCTKPath string
|
nvidiaCTKPath string
|
||||||
mode string
|
mode string
|
||||||
kind string
|
|
||||||
vendor string
|
vendor string
|
||||||
class string
|
class string
|
||||||
}
|
}
|
||||||
@ -114,17 +111,18 @@ func (m command) build() *cli.Command {
|
|||||||
Destination: &cfg.nvidiaCTKPath,
|
Destination: &cfg.nvidiaCTKPath,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "target-driver-root",
|
Name: "vendor",
|
||||||
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.",
|
Aliases: []string{"cdi-vendor"},
|
||||||
Value: "",
|
Usage: "the vendor string to use for the generated CDI specification.",
|
||||||
Destination: &cfg.targetDriverRoot,
|
Value: "nvidia.com",
|
||||||
|
Destination: &cfg.vendor,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "kind",
|
Name: "class",
|
||||||
Aliases: []string{"cdi-kind"},
|
Aliases: []string{"cdi-class"},
|
||||||
Usage: "the vendor string to use for the generated CDI specification.",
|
Usage: "the class string to use for the generated CDI specification.",
|
||||||
Value: "nvidia.com/gpu",
|
Value: "gpu",
|
||||||
Destination: &cfg.kind,
|
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)
|
cfg.nvidiaCTKPath = discover.FindNvidiaCTK(m.logger, cfg.nvidiaCTKPath)
|
||||||
|
|
||||||
if cfg.targetDriverRoot == "" {
|
|
||||||
cfg.targetDriverRoot = cfg.driverRoot
|
|
||||||
}
|
|
||||||
|
|
||||||
if outputFileFormat := formatFromFilename(cfg.output); outputFileFormat != "" {
|
if outputFileFormat := formatFromFilename(cfg.output); outputFileFormat != "" {
|
||||||
m.logger.Debugf("Inferred output format as %q from output file name", outputFileFormat)
|
m.logger.Debugf("Inferred output format as %q from output file name", outputFileFormat)
|
||||||
if !c.IsSet("format") {
|
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(cfg.vendor); err != nil {
|
||||||
if err := cdi.ValidateVendorName(vendor); err != nil {
|
|
||||||
return fmt.Errorf("invalid CDI vendor name: %v", err)
|
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)
|
return fmt.Errorf("invalid CDI class name: %v", err)
|
||||||
}
|
}
|
||||||
cfg.vendor = vendor
|
|
||||||
cfg.class = class
|
|
||||||
|
|
||||||
return nil
|
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)
|
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.WithVendor(cfg.vendor),
|
||||||
spec.WithClass(cfg.class),
|
spec.WithClass(cfg.class),
|
||||||
spec.WithDeviceSpecs(deviceSpecs),
|
spec.WithDeviceSpecs(deviceSpecs),
|
||||||
spec.WithEdits(*commonEdits.ContainerEdits),
|
spec.WithEdits(*commonEdits.ContainerEdits),
|
||||||
spec.WithFormat(cfg.format),
|
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.
|
// MergeDeviceSpecs creates a device with the specified name which combines the edits from the previous devices.
|
||||||
|
Loading…
Reference in New Issue
Block a user