Skip to content

Commit 55029b7

Browse files
committed
cmd/cdi: validate also Spec version.
Signed-off-by: Krisztian Litkey <[email protected]>
1 parent 286336b commit 55029b7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cmd/cdi/cmd/validate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/spf13/cobra"
2525

2626
"tags.cncf.io/container-device-interface/pkg/cdi"
27+
"tags.cncf.io/container-device-interface/specs-go"
2728
)
2829

2930
// validateCmd is our CDI command for validating CDI Spec files in the cache.
@@ -49,6 +50,15 @@ were reported by the cache.`,
4950
fmt.Printf(" %2d: %v\n", idx, strings.TrimSpace(err.Error()))
5051
}
5152
}
53+
54+
for _, v := range cache.ListVendors() {
55+
for _, s := range cache.GetVendorSpecs(v) {
56+
if err := specs.ValidateVersion(s.Spec); err != nil {
57+
fmt.Printf("Spec file %s failed version validation: %v\n", s.GetPath(), err)
58+
}
59+
}
60+
}
61+
5262
os.Exit(1)
5363
},
5464
}

cmd/cdi/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
sigs.k8s.io/yaml v1.4.0
1212
tags.cncf.io/container-device-interface v1.0.1
1313
tags.cncf.io/container-device-interface/schema v0.0.0
14+
tags.cncf.io/container-device-interface/specs-go v1.0.0
1415
)
1516

1617
require (
@@ -22,7 +23,6 @@ require (
2223
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
2324
golang.org/x/mod v0.19.0 // indirect
2425
golang.org/x/sys v0.19.0 // indirect
25-
tags.cncf.io/container-device-interface/specs-go v1.0.0 // indirect
2626
)
2727

2828
replace (

0 commit comments

Comments
 (0)