Skip to content

Commit 22b6a2a

Browse files
committed
cmd/cdi: update validation Schema setting.
Signed-off-by: Krisztian Litkey <[email protected]>
1 parent fbd7943 commit 22b6a2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/cdi/cmd/root.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"github.com/spf13/cobra"
2424

2525
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
26+
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/validate"
27+
"github.com/container-orchestrated-devices/container-device-interface/schema"
2628
)
2729

2830
var (
@@ -58,14 +60,17 @@ func init() {
5860
}
5961

6062
func initSpecDirs() {
61-
err := cdi.SetSchema(schemaName)
63+
s, err := schema.Load(schemaName)
6264
if err != nil {
6365
fmt.Printf("failed to load JSON schema %s: %v\n", schemaName, err)
6466
os.Exit(1)
6567
}
68+
cdi.SetSpecValidator(validate.WithSchema(s))
6669

6770
if len(specDirs) > 0 {
68-
cdi.GetRegistry(cdi.WithSpecDirs(specDirs...))
71+
cdi.GetRegistry(
72+
cdi.WithSpecDirs(specDirs...),
73+
)
6974
if len(cdi.GetRegistry().GetErrors()) > 0 {
7075
cdiPrintRegistryErrors()
7176
}

0 commit comments

Comments
 (0)