From 02c83b16ceea7af823b11e03cebe204ef9ce7b2e Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 16 Jul 2026 13:03:14 +0300 Subject: [PATCH] cmd/cdi: respect the --spec-dirs flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, don't bail out on spec dir errors – behave similarly to default spec dirs. Signed-off-by: Markus Lehtonen --- cmd/cdi/cmd/cdi-api.go | 3 +-- cmd/cdi/cmd/root.go | 11 ++--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cmd/cdi/cmd/cdi-api.go b/cmd/cdi/cmd/cdi-api.go index 0fc5baeb..3899e2c9 100644 --- a/cmd/cdi/cmd/cdi-api.go +++ b/cmd/cdi/cmd/cdi-api.go @@ -182,14 +182,13 @@ func cdiInjectDevices(format string, ociSpec *oci.Spec, patterns []string) error func cdiResolveDevices(ociSpecFiles ...string) error { var ( - cache *cdi.Cache + cache = cdi.GetDefaultCache() ociSpec *oci.Spec devices []string unresolved []string err error ) - cache, _ = cdi.NewCache() for _, ociSpecFile := range ociSpecFiles { ociSpec, err = readOCISpec(ociSpecFile) diff --git a/cmd/cdi/cmd/root.go b/cmd/cdi/cmd/root.go index a2db5c20..85c586a6 100644 --- a/cmd/cdi/cmd/root.go +++ b/cmd/cdi/cmd/root.go @@ -67,15 +67,8 @@ func initSpecDirs() { cdi.SetSpecValidator(schema.WithSchema(s)) if len(specDirs) > 0 { - cache, err := cdi.NewCache( - cdi.WithSpecDirs(specDirs...), - ) - if err != nil { - fmt.Printf("failed to create CDI cache: %v\n", err) - os.Exit(1) - } - if len(cache.GetErrors()) > 0 { - cdiPrintCacheErrors() + if err := cdi.Configure(cdi.WithSpecDirs(specDirs...)); err != nil { + fmt.Printf("failed to configure CDI cache: %v\n", err) os.Exit(1) } }