Bump tags.cncf.io/container-device-interface from 0.7.2 to 0.8.0

Bumps [tags.cncf.io/container-device-interface](https://github.com/cncf-tags/container-device-interface) from 0.7.2 to 0.8.0.
- [Release notes](https://github.com/cncf-tags/container-device-interface/releases)
- [Commits](https://github.com/cncf-tags/container-device-interface/compare/v0.7.2...v0.8.0)

---
updated-dependencies:
- dependency-name: tags.cncf.io/container-device-interface
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2024-07-09 11:48:04 +00:00 committed by GitHub
parent 46838b1a44
commit 0c309df7e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 149 additions and 54 deletions

4
go.mod
View File

@ -13,8 +13,8 @@ require (
github.com/urfave/cli/v2 v2.27.2 github.com/urfave/cli/v2 v2.27.2
golang.org/x/mod v0.18.0 golang.org/x/mod v0.18.0
golang.org/x/sys v0.21.0 golang.org/x/sys v0.21.0
tags.cncf.io/container-device-interface v0.7.2 tags.cncf.io/container-device-interface v0.8.0
tags.cncf.io/container-device-interface/specs-go v0.7.0 tags.cncf.io/container-device-interface/specs-go v0.8.0
) )
require ( require (

8
go.sum
View File

@ -86,7 +86,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
tags.cncf.io/container-device-interface v0.7.2 h1:MLqGnWfOr1wB7m08ieI4YJ3IoLKKozEnnNYBtacDPQU= tags.cncf.io/container-device-interface v0.8.0 h1:8bCFo/g9WODjWx3m6EYl3GfUG31eKJbaggyBDxEldRc=
tags.cncf.io/container-device-interface v0.7.2/go.mod h1:Xb1PvXv2BhfNb3tla4r9JL129ck1Lxv9KuU6eVOfKto= tags.cncf.io/container-device-interface v0.8.0/go.mod h1:Apb7N4VdILW0EVdEMRYXIDVRZfNJZ+kmEUss2kRRQ6Y=
tags.cncf.io/container-device-interface/specs-go v0.7.0 h1:w/maMGVeLP6TIQJVYT5pbqTi8SCw/iHZ+n4ignuGHqg= tags.cncf.io/container-device-interface/specs-go v0.8.0 h1:QYGFzGxvYK/ZLMrjhvY0RjpUavIn4KcmRmVP/JjdBTA=
tags.cncf.io/container-device-interface/specs-go v0.7.0/go.mod h1:hMAwAbMZyBLdmYqWgYcKH0F/yctNpV3P35f+/088A80= tags.cncf.io/container-device-interface/specs-go v0.8.0/go.mod h1:BhJIkjjPh4qpys+qm4DAYtUyryaTDg9zris+AczXyws=

4
vendor/modules.txt vendored
View File

@ -83,12 +83,12 @@ gopkg.in/yaml.v3
# sigs.k8s.io/yaml v1.3.0 # sigs.k8s.io/yaml v1.3.0
## explicit; go 1.12 ## explicit; go 1.12
sigs.k8s.io/yaml sigs.k8s.io/yaml
# tags.cncf.io/container-device-interface v0.7.2 # tags.cncf.io/container-device-interface v0.8.0
## explicit; go 1.20 ## explicit; go 1.20
tags.cncf.io/container-device-interface/internal/validation tags.cncf.io/container-device-interface/internal/validation
tags.cncf.io/container-device-interface/internal/validation/k8s tags.cncf.io/container-device-interface/internal/validation/k8s
tags.cncf.io/container-device-interface/pkg/cdi tags.cncf.io/container-device-interface/pkg/cdi
tags.cncf.io/container-device-interface/pkg/parser tags.cncf.io/container-device-interface/pkg/parser
# tags.cncf.io/container-device-interface/specs-go v0.7.0 # tags.cncf.io/container-device-interface/specs-go v0.8.0
## explicit; go 1.19 ## explicit; go 1.19
tags.cncf.io/container-device-interface/specs-go tags.cncf.io/container-device-interface/specs-go

View File

@ -89,7 +89,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
if err != nil { if err != nil {
return err return err
} }
dev := d.ToOCI() dev := dn.toOCI()
if dev.UID == nil && spec.Process != nil { if dev.UID == nil && spec.Process != nil {
if uid := spec.Process.User.UID; uid > 0 { if uid := spec.Process.User.UID; uid > 0 {
dev.UID = &uid dev.UID = &uid
@ -116,29 +116,30 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
if len(e.Mounts) > 0 { if len(e.Mounts) > 0 {
for _, m := range e.Mounts { for _, m := range e.Mounts {
specgen.RemoveMount(m.ContainerPath) specgen.RemoveMount(m.ContainerPath)
specgen.AddMount(m.ToOCI()) specgen.AddMount((&Mount{m}).toOCI())
} }
sortMounts(&specgen) sortMounts(&specgen)
} }
for _, h := range e.Hooks { for _, h := range e.Hooks {
ociHook := (&Hook{h}).toOCI()
switch h.HookName { switch h.HookName {
case PrestartHook: case PrestartHook:
specgen.AddPreStartHook(h.ToOCI()) specgen.AddPreStartHook(ociHook)
case PoststartHook: case PoststartHook:
specgen.AddPostStartHook(h.ToOCI()) specgen.AddPostStartHook(ociHook)
case PoststopHook: case PoststopHook:
specgen.AddPostStopHook(h.ToOCI()) specgen.AddPostStopHook(ociHook)
// TODO: Maybe runtime-tools/generate should be updated with these... // TODO: Maybe runtime-tools/generate should be updated with these...
case CreateRuntimeHook: case CreateRuntimeHook:
ensureOCIHooks(spec) ensureOCIHooks(spec)
spec.Hooks.CreateRuntime = append(spec.Hooks.CreateRuntime, h.ToOCI()) spec.Hooks.CreateRuntime = append(spec.Hooks.CreateRuntime, ociHook)
case CreateContainerHook: case CreateContainerHook:
ensureOCIHooks(spec) ensureOCIHooks(spec)
spec.Hooks.CreateContainer = append(spec.Hooks.CreateContainer, h.ToOCI()) spec.Hooks.CreateContainer = append(spec.Hooks.CreateContainer, ociHook)
case StartContainerHook: case StartContainerHook:
ensureOCIHooks(spec) ensureOCIHooks(spec)
spec.Hooks.StartContainer = append(spec.Hooks.StartContainer, h.ToOCI()) spec.Hooks.StartContainer = append(spec.Hooks.StartContainer, ociHook)
default: default:
return fmt.Errorf("unknown hook name %q", h.HookName) return fmt.Errorf("unknown hook name %q", h.HookName)
} }
@ -148,7 +149,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
// The specgen is missing functionality to set all parameters so we // The specgen is missing functionality to set all parameters so we
// just piggy-back on it to initialize all structs and the copy over. // just piggy-back on it to initialize all structs and the copy over.
specgen.SetLinuxIntelRdtClosID(e.IntelRdt.ClosID) specgen.SetLinuxIntelRdtClosID(e.IntelRdt.ClosID)
spec.Linux.IntelRdt = e.IntelRdt.ToOCI() spec.Linux.IntelRdt = (&IntelRdt{e.IntelRdt}).toOCI()
} }
for _, additionalGID := range e.AdditionalGIDs { for _, additionalGID := range e.AdditionalGIDs {
@ -186,7 +187,7 @@ func (e *ContainerEdits) Validate() error {
} }
} }
if e.IntelRdt != nil { if e.IntelRdt != nil {
if err := ValidateIntelRdt(e.IntelRdt); err != nil { if err := (&IntelRdt{e.IntelRdt}).Validate(); err != nil {
return err return err
} }
} }
@ -321,8 +322,21 @@ func (m *Mount) Validate() error {
return nil return nil
} }
// IntelRdt is a CDI IntelRdt wrapper.
// This is used for validation and conversion to OCI specifications.
type IntelRdt struct {
*specs.IntelRdt
}
// ValidateIntelRdt validates the IntelRdt configuration. // ValidateIntelRdt validates the IntelRdt configuration.
//
// Deprecated: ValidateIntelRdt is deprecated use IntelRdt.Validate() instead.
func ValidateIntelRdt(i *specs.IntelRdt) error { func ValidateIntelRdt(i *specs.IntelRdt) error {
return (&IntelRdt{i}).Validate()
}
// Validate validates the IntelRdt configuration.
func (i *IntelRdt) Validate() error {
// ClosID must be a valid Linux filename // ClosID must be a valid Linux filename
if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") { if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") {
return errors.New("invalid ClosID") return errors.New("invalid ClosID")

View File

@ -0,0 +1,65 @@
/*
Copyright © 2021 The CDI Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cdi
import (
spec "github.com/opencontainers/runtime-spec/specs-go"
)
// toOCI returns the opencontainers runtime Spec Hook for this Hook.
func (h *Hook) toOCI() spec.Hook {
return spec.Hook{
Path: h.Path,
Args: h.Args,
Env: h.Env,
Timeout: h.Timeout,
}
}
// toOCI returns the opencontainers runtime Spec Mount for this Mount.
func (m *Mount) toOCI() spec.Mount {
return spec.Mount{
Source: m.HostPath,
Destination: m.ContainerPath,
Options: m.Options,
Type: m.Type,
}
}
// toOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode.
func (d *DeviceNode) toOCI() spec.LinuxDevice {
return spec.LinuxDevice{
Path: d.Path,
Type: d.Type,
Major: d.Major,
Minor: d.Minor,
FileMode: d.FileMode,
UID: d.UID,
GID: d.GID,
}
}
// toOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config.
func (i *IntelRdt) toOCI() *spec.LinuxIntelRdt {
return &spec.LinuxIntelRdt{
ClosID: i.ClosID,
L3CacheSchema: i.L3CacheSchema,
MemBwSchema: i.MemBwSchema,
EnableCMT: i.EnableCMT,
EnableMBM: i.EnableMBM,
}
}

View File

@ -40,6 +40,7 @@ const (
v050 version = "v0.5.0" v050 version = "v0.5.0"
v060 version = "v0.6.0" v060 version = "v0.6.0"
v070 version = "v0.7.0" v070 version = "v0.7.0"
v080 version = "v0.8.0"
// vEarliest is the earliest supported version of the CDI specification // vEarliest is the earliest supported version of the CDI specification
vEarliest version = v030 vEarliest version = v030
@ -56,6 +57,7 @@ var validSpecVersions = requiredVersionMap{
v050: requiresV050, v050: requiresV050,
v060: requiresV060, v060: requiresV060,
v070: requiresV070, v070: requiresV070,
v080: requiresV080,
} }
// MinimumRequiredVersion determines the minimum spec version for the input spec. // MinimumRequiredVersion determines the minimum spec version for the input spec.
@ -120,6 +122,13 @@ func (r requiredVersionMap) requiredVersion(spec *cdi.Spec) version {
return minVersion return minVersion
} }
// requiresV080 returns true if the spec uses v0.8.0 features.
// Since the v0.8.0 spec bump was due to the removed .ToOCI functions on the
// spec types, there are explicit spec changes.
func requiresV080(_ *cdi.Spec) bool {
return false
}
// requiresV070 returns true if the spec uses v0.7.0 features // requiresV070 returns true if the spec uses v0.7.0 features
func requiresV070(spec *cdi.Spec) bool { func requiresV070(spec *cdi.Spec) bool {
if spec.ContainerEdits.IntelRdt != nil { if spec.ContainerEdits.IntelRdt != nil {

View File

@ -3,7 +3,7 @@ package specs
import "os" import "os"
// CurrentVersion is the current version of the Spec. // CurrentVersion is the current version of the Spec.
const CurrentVersion = "0.7.0" const CurrentVersion = "0.8.0"
// Spec is the base configuration for CDI // Spec is the base configuration for CDI
type Spec struct { type Spec struct {

View File

@ -1,49 +1,56 @@
/*
Copyright © 2021 The CDI Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package specs package specs
import ( import "errors"
spec "github.com/opencontainers/runtime-spec/specs-go"
) // errDeprecated is returned for the ToOCI functions below.
// This should provide better guidance for user when migrating from the API
// below to the APIs provided in the cdi package.
var errDeprecated = errors.New("deprecated; Use cdi package functions instead")
// ToOCI returns the opencontainers runtime Spec Hook for this Hook. // ToOCI returns the opencontainers runtime Spec Hook for this Hook.
func (h *Hook) ToOCI() spec.Hook { //
return spec.Hook{ // Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.Hook.toOCI
Path: h.Path, // and made private.
Args: h.Args, func (h *Hook) ToOCI() error {
Env: h.Env, return errDeprecated
Timeout: h.Timeout,
}
} }
// ToOCI returns the opencontainers runtime Spec Mount for this Mount. // ToOCI returns the opencontainers runtime Spec Mount for this Mount.
func (m *Mount) ToOCI() spec.Mount { //
return spec.Mount{ // Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.Mount.toOCI
Source: m.HostPath, // and made private.
Destination: m.ContainerPath, func (m *Mount) ToOCI() error {
Options: m.Options, return errDeprecated
Type: m.Type,
}
} }
// ToOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode. // ToOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode.
func (d *DeviceNode) ToOCI() spec.LinuxDevice { //
return spec.LinuxDevice{ // Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.DeviceNode.toOCI
Path: d.Path, // and made private.
Type: d.Type, func (d *DeviceNode) ToOCI() error {
Major: d.Major, return errDeprecated
Minor: d.Minor,
FileMode: d.FileMode,
UID: d.UID,
GID: d.GID,
}
} }
// ToOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config. // ToOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config.
func (i *IntelRdt) ToOCI() *spec.LinuxIntelRdt { //
return &spec.LinuxIntelRdt{ // Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.IntelRdt.toOCI
ClosID: i.ClosID, // and made private.
L3CacheSchema: i.L3CacheSchema, func (i *IntelRdt) ToOCI() error {
MemBwSchema: i.MemBwSchema, return errDeprecated
EnableCMT: i.EnableCMT,
EnableMBM: i.EnableMBM,
}
} }