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)
// Construct the spec
// TODO: Use the code to determine the minimal version
// We construct the spec and determine the minimum required version based on the specification.
spec := specs.Spec{
Version: "0.4.0",
Version: "NOT_SET",
Kind: "nvidia.com/gpu",
Devices: deviceSpecs,
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
}