Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/cdi/cmd/cdi-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 2 additions & 9 deletions cmd/cdi/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we now still print any cache errors after this change ? If not then we should readd/do it here IMO (without bailing out on errors).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the sub-command. For validate, yes we do.

But the main idea I had is, work the same way independent whether we use the default spec dirs or user-specified spec dirs.

fmt.Printf("failed to configure CDI cache: %v\n", err)
os.Exit(1)
}
}
Expand Down
Loading