From b30799ece157cdb72214d6e99bca46b808475339 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 22 Oct 2024 14:26:38 +0200 Subject: [PATCH] Ensure that YAML fields are sorted Signed-off-by: Evan Lezar --- cmd/cdi/cmd/format.go | 2 +- cmd/cdi/cmd/inject.go | 2 +- cmd/cdi/go.mod | 3 +- cmd/cdi/go.sum | 2 -- cmd/validate/go.mod | 1 - cmd/validate/go.sum | 3 -- go.mod | 3 +- go.sum | 2 -- pkg/cdi/cache_test.go | 3 +- pkg/cdi/spec.go | 2 +- pkg/cdi/spec_test.go | 2 +- schema/schema.go | 2 +- specs-go/config.go | 74 +++++++++++++++++++++---------------------- 13 files changed, 46 insertions(+), 55 deletions(-) diff --git a/cmd/cdi/cmd/format.go b/cmd/cdi/cmd/format.go index 33726964..f5c56c3b 100644 --- a/cmd/cdi/cmd/format.go +++ b/cmd/cdi/cmd/format.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "sigs.k8s.io/yaml" + "gopkg.in/yaml.v2" ) func chooseFormat(format string, path string) string { diff --git a/cmd/cdi/cmd/inject.go b/cmd/cdi/cmd/inject.go index b630ec2a..a82b1ec8 100644 --- a/cmd/cdi/cmd/inject.go +++ b/cmd/cdi/cmd/inject.go @@ -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" ) diff --git a/cmd/cdi/go.mod b/cmd/cdi/go.mod index 5635434d..2a613afa 100644 --- a/cmd/cdi/go.mod +++ b/cmd/cdi/go.mod @@ -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 ) @@ -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 ) diff --git a/cmd/cdi/go.sum b/cmd/cdi/go.sum index 58bedc5e..edc666ea 100644 --- a/cmd/cdi/go.sum +++ b/cmd/cdi/go.sum @@ -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= diff --git a/cmd/validate/go.mod b/cmd/validate/go.mod index 1d5c8701..8c943d56 100644 --- a/cmd/validate/go.mod +++ b/cmd/validate/go.mod @@ -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 => ../.. diff --git a/cmd/validate/go.sum b/cmd/validate/go.sum index 578a08c5..d8126c25 100644 --- a/cmd/validate/go.sum +++ b/cmd/validate/go.sum @@ -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= @@ -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= diff --git a/go.mod b/go.mod index 8cda9399..519084e5 100644 --- a/go.mod +++ b/go.mod @@ -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 ) @@ -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 ) diff --git a/go.sum b/go.sum index beba3859..2df9d938 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/cdi/cache_test.go b/pkg/cdi/cache_test.go index 3c655116..2c90491f 100644 --- a/pkg/cdi/cache_test.go +++ b/pkg/cdi/cache_test.go @@ -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" ) diff --git a/pkg/cdi/spec.go b/pkg/cdi/spec.go index f0231d81..b791a1b0 100644 --- a/pkg/cdi/spec.go +++ b/pkg/cdi/spec.go @@ -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" diff --git a/pkg/cdi/spec_test.go b/pkg/cdi/spec_test.go index 649d2237..4273438c 100644 --- a/pkg/cdi/spec_test.go +++ b/pkg/cdi/spec_test.go @@ -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" diff --git a/schema/schema.go b/schema/schema.go index 6a582ca1..5d82a814 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -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" diff --git a/specs-go/config.go b/specs-go/config.go index 77f095c0..f28657b8 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -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"` }