Determine the minumum required spec version

This change uses functionality from the CDI package to determine
the minimum required CDI spec version. This allows for a spec with
the widest compatibility to be specified.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-01-19 11:48:36 +01:00
parent bc4bfb94a2
commit eaf9bdaeb4

View File

@ -249,15 +249,20 @@ func (m command) generateSpec(root string, nvidiaCTKPath string) (*specs.Spec, e
allEdits.Append(commonEdits) allEdits.Append(commonEdits)
// Construct the spec // We construct the spec and determine the minimum required version based on the specification.
// TODO: Use the code to determine the minimal version
spec := specs.Spec{ spec := specs.Spec{
Version: "0.4.0", Version: "NOT_SET",
Kind: "nvidia.com/gpu", Kind: "nvidia.com/gpu",
Devices: deviceSpecs, Devices: deviceSpecs,
ContainerEdits: *allEdits.ContainerEdits, ContainerEdits: *allEdits.ContainerEdits,
} }
minVersion, err := cdi.MinimumRequiredVersion(&spec)
if err != nil {
return nil, fmt.Errorf("failed to get minumum required CDI spec version: %v", err)
}
spec.Version = minVersion
return &spec, nil return &spec, nil
} }