Skip to content

Commit

Permalink
Ensure that YAML fields are sorted
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Oct 22, 2024
1 parent 44fef1d commit b30799e
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 55 deletions.
2 changes: 1 addition & 1 deletion cmd/cdi/cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path/filepath"
"strings"

"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"
)

func chooseFormat(format string, path string) string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cdi/cmd/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"

oci "github.com/opencontainers/runtime-spec/specs-go"
"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"

"github.com/spf13/cobra"
)
Expand Down
3 changes: 1 addition & 2 deletions cmd/cdi/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/opencontainers/runtime-spec v1.1.0
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626
github.com/spf13/cobra v1.6.0
sigs.k8s.io/yaml v1.3.0
gopkg.in/yaml.v2 v2.4.0
tags.cncf.io/container-device-interface v0.0.0
)

Expand All @@ -21,7 +21,6 @@ require (
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sys v0.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
tags.cncf.io/container-device-interface/specs-go v0.8.0 // indirect
)

Expand Down
2 changes: 0 additions & 2 deletions cmd/cdi/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
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/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
1 change: 0 additions & 1 deletion cmd/validate/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace tags.cncf.io/container-device-interface => ../..
Expand Down
3 changes: 0 additions & 3 deletions cmd/validate/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg=
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 h1:DmNGcqH3WDbV5k8OJ+esPWbqUOX5rMLR2PMvziDMJi0=
Expand All @@ -23,5 +22,3 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/stretchr/testify v1.7.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/sys v0.1.0
sigs.k8s.io/yaml v1.3.0
gopkg.in/yaml.v2 v2.4.0
tags.cncf.io/container-device-interface/specs-go v0.8.0
)

Expand All @@ -20,7 +20,6 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
golang.org/x/mod v0.19.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
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/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
3 changes: 2 additions & 1 deletion pkg/cdi/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (

oci "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"

"tags.cncf.io/container-device-interface/pkg/cdi/validate"
cdi "tags.cncf.io/container-device-interface/specs-go"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cdi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sync"

oci "github.com/opencontainers/runtime-spec/specs-go"
"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"

"tags.cncf.io/container-device-interface/internal/validation"
"tags.cncf.io/container-device-interface/pkg/parser"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cdi/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"testing"

"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"

"github.com/stretchr/testify/require"
"tags.cncf.io/container-device-interface/pkg/cdi/validate"
Expand Down
2 changes: 1 addition & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"path/filepath"
"strings"

"sigs.k8s.io/yaml"
"gopkg.in/yaml.v2"

schema "github.com/xeipuuv/gojsonschema"
"tags.cncf.io/container-device-interface/internal/validation"
Expand Down
74 changes: 37 additions & 37 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,69 @@ import "os"

// Spec is the base configuration for CDI
type Spec struct {
Version string `json:"cdiVersion"`
Kind string `json:"kind"`
Version string `json:"cdiVersion" yaml:"cdiVersion"`
Kind string `json:"kind" yaml:"kind"`
// Annotations add meta information per CDI spec. Note these are CDI-specific and do not affect container metadata.
// Added in v0.6.0.
Annotations map[string]string `json:"annotations,omitempty"`
Devices []Device `json:"devices"`
ContainerEdits ContainerEdits `json:"containerEdits,omitempty"`
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
Devices []Device `json:"devices" yaml:"devices"`
ContainerEdits ContainerEdits `json:"containerEdits,omitempty" yaml:"containerEdits,omitempty"`
}

// Device is a "Device" a container runtime can add to a container
type Device struct {
Name string `json:"name"`
Name string `json:"name" yaml:"name"`
// Annotations add meta information per device. Note these are CDI-specific and do not affect container metadata.
// Added in v0.6.0.
Annotations map[string]string `json:"annotations,omitempty"`
ContainerEdits ContainerEdits `json:"containerEdits"`
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
ContainerEdits ContainerEdits `json:"containerEdits" yaml:"containerEdits"`
}

// ContainerEdits are edits a container runtime must make to the OCI spec to expose the device.
type ContainerEdits struct {
Env []string `json:"env,omitempty"`
DeviceNodes []*DeviceNode `json:"deviceNodes,omitempty"`
Hooks []*Hook `json:"hooks,omitempty"`
Mounts []*Mount `json:"mounts,omitempty"`
IntelRdt *IntelRdt `json:"intelRdt,omitempty"` // Added in v0.7.0
AdditionalGIDs []uint32 `json:"additionalGids,omitempty"` // Added in v0.7.0
Env []string `json:"env,omitempty" yaml:"env,omitempty"`
DeviceNodes []*DeviceNode `json:"deviceNodes,omitempty" yaml:"deviceNodes,omitempty"`
Hooks []*Hook `json:"hooks,omitempty" yaml:"hooks,omitempty"`
Mounts []*Mount `json:"mounts,omitempty" yaml:"mounts,omitempty"`
IntelRdt *IntelRdt `json:"intelRdt,omitempty" yaml:"intelRdt,omitempty"` // Added in v0.7.0
AdditionalGIDs []uint32 `json:"additionalGids,omitempty" yaml:"additionalGids,omitempty"` // Added in v0.7.0
}

// DeviceNode represents a device node that needs to be added to the OCI spec.
type DeviceNode struct {
Path string `json:"path"`
HostPath string `json:"hostPath,omitempty"` // Added in v0.5.0
Type string `json:"type,omitempty"`
Major int64 `json:"major,omitempty"`
Minor int64 `json:"minor,omitempty"`
FileMode *os.FileMode `json:"fileMode,omitempty"`
Permissions string `json:"permissions,omitempty"`
UID *uint32 `json:"uid,omitempty"`
GID *uint32 `json:"gid,omitempty"`
Path string `json:"path" yaml:"path"`
HostPath string `json:"hostPath,omitempty" yaml:"hostPath,omitempty"` // Added in v0.5.0
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Major int64 `json:"major,omitempty" yaml:"major,omitempty"`
Minor int64 `json:"minor,omitempty" yaml:"minor,omitempty"`
FileMode *os.FileMode `json:"fileMode,omitempty" yaml:"fileMode,omitempty"`
Permissions string `json:"permissions,omitempty" yaml:"permissions,omitempty"`
UID *uint32 `json:"uid,omitempty" yaml:"uid,omitempty"`
GID *uint32 `json:"gid,omitempty" yaml:"gid,omitempty"`
}

// Mount represents a mount that needs to be added to the OCI spec.
type Mount struct {
HostPath string `json:"hostPath"`
ContainerPath string `json:"containerPath"`
Options []string `json:"options,omitempty"`
Type string `json:"type,omitempty"` // Added in v0.4.0
HostPath string `json:"hostPath" yaml:"hostPath"`
ContainerPath string `json:"containerPath" yaml:"containerPath"`
Options []string `json:"options,omitempty" yaml:"options,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"` // Added in v0.4.0
}

// Hook represents a hook that needs to be added to the OCI spec.
type Hook struct {
HookName string `json:"hookName"`
Path string `json:"path"`
Args []string `json:"args,omitempty"`
Env []string `json:"env,omitempty"`
Timeout *int `json:"timeout,omitempty"`
HookName string `json:"hookName" yaml:"hookName"`
Path string `json:"path" yaml:"path"`
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
Env []string `json:"env,omitempty" yaml:"env,omitempty"`
Timeout *int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

// IntelRdt describes the Linux IntelRdt parameters to set in the OCI spec.
type IntelRdt struct {
ClosID string `json:"closID,omitempty"`
L3CacheSchema string `json:"l3CacheSchema,omitempty"`
MemBwSchema string `json:"memBwSchema,omitempty"`
EnableCMT bool `json:"enableCMT,omitempty"`
EnableMBM bool `json:"enableMBM,omitempty"`
ClosID string `json:"closID,omitempty" yaml:"closID,omitempty"`
L3CacheSchema string `json:"l3CacheSchema,omitempty" yaml:"l3CacheSchema,omitempty"`
MemBwSchema string `json:"memBwSchema,omitempty" yaml:"memBwSchema,omitempty"`
EnableCMT bool `json:"enableCMT,omitempty" yaml:"enableCMT,omitempty"`
EnableMBM bool `json:"enableMBM,omitempty" yaml:"enableMBM,omitempty"`
}

0 comments on commit b30799e

Please sign in to comment.