@@ -28,7 +28,6 @@ import (
2828
2929 "github.com/fsnotify/fsnotify"
3030 oci "github.com/opencontainers/runtime-spec/specs-go"
31- "tags.cncf.io/container-device-interface/internal/multierror"
3231 cdi "tags.cncf.io/container-device-interface/specs-go"
3332)
3433
@@ -133,11 +132,11 @@ func (c *Cache) Refresh() error {
133132 }
134133
135134 // collect and return cached errors, much like refresh() does it
136- var result error
137- for _ , errors := range c .errors {
138- result = multierror . Append ( result , errors ... )
135+ errs := [] error {}
136+ for _ , specErrs := range c .errors {
137+ errs = append ( errs , errors .Join ( specErrs ... ) )
139138 }
140- return result
139+ return errors . Join ( errs ... )
141140}
142141
143142// Refresh the Cache by rescanning CDI Spec directories and files.
@@ -147,12 +146,10 @@ func (c *Cache) refresh() error {
147146 devices = map [string ]* Device {}
148147 conflicts = map [string ]struct {}{}
149148 specErrors = map [string ][]error {}
150- result []error
151149 )
152150
153151 // collect errors per spec file path and once globally
154152 collectError := func (err error , paths ... string ) {
155- result = append (result , err )
156153 for _ , path := range paths {
157154 specErrors [path ] = append (specErrors [path ], err )
158155 }
@@ -205,7 +202,11 @@ func (c *Cache) refresh() error {
205202 c .devices = devices
206203 c .errors = specErrors
207204
208- return multierror .New (result ... )
205+ errs := []error {}
206+ for _ , specErrs := range specErrors {
207+ errs = append (errs , errors .Join (specErrs ... ))
208+ }
209+ return errors .Join (errs ... )
209210}
210211
211212// RefreshIfRequired triggers a refresh if necessary.
0 commit comments