Skip to content

Commit 78c6041

Browse files
committed
pkg/cdi: address complaints by golangci-lint.
Signed-off-by: Krisztian Litkey <[email protected]>
1 parent b414729 commit 78c6041

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

pkg/cdi/cache.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c *Cache) configure(options ...Option) {
116116
c.watch.setup(c.specDirs, c.dirErrors)
117117
c.watch.start(&c.Mutex, c.refresh, c.dirErrors)
118118
}
119-
c.refresh()
119+
_ = c.refresh() // we record but ignore errors
120120
}
121121

122122
// Refresh rescans the CDI Spec directories and refreshes the Cache.
@@ -233,7 +233,7 @@ func (c *Cache) InjectDevices(ociSpec *oci.Spec, devices ...string) ([]string, e
233233
c.Lock()
234234
defer c.Unlock()
235235

236-
c.refreshIfRequired(false)
236+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
237237

238238
edits := &ContainerEdits{}
239239
specs := map[*Spec]struct{}{}
@@ -340,7 +340,7 @@ func (c *Cache) GetDevice(device string) *Device {
340340
c.Lock()
341341
defer c.Unlock()
342342

343-
c.refreshIfRequired(false)
343+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
344344

345345
return c.devices[device]
346346
}
@@ -352,7 +352,7 @@ func (c *Cache) ListDevices() []string {
352352
c.Lock()
353353
defer c.Unlock()
354354

355-
c.refreshIfRequired(false)
355+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
356356

357357
for name := range c.devices {
358358
devices = append(devices, name)
@@ -369,7 +369,7 @@ func (c *Cache) ListVendors() []string {
369369
c.Lock()
370370
defer c.Unlock()
371371

372-
c.refreshIfRequired(false)
372+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
373373

374374
for vendor := range c.specs {
375375
vendors = append(vendors, vendor)
@@ -389,7 +389,7 @@ func (c *Cache) ListClasses() []string {
389389
c.Lock()
390390
defer c.Unlock()
391391

392-
c.refreshIfRequired(false)
392+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
393393

394394
for _, specs := range c.specs {
395395
for _, spec := range specs {
@@ -409,7 +409,7 @@ func (c *Cache) GetVendorSpecs(vendor string) []*Spec {
409409
c.Lock()
410410
defer c.Unlock()
411411

412-
c.refreshIfRequired(false)
412+
_, _ = c.refreshIfRequired(false) // we record but ignore errors
413413

414414
return c.specs[vendor]
415415
}
@@ -544,7 +544,7 @@ func (w *watch) watch(fsw *fsnotify.Watcher, m *sync.Mutex, refresh func() error
544544
} else {
545545
w.update(dirErrors)
546546
}
547-
refresh()
547+
_ = refresh()
548548
m.Unlock()
549549

550550
case _, ok := <-watch.Errors:

pkg/cdi/default-cache_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ devices:
115115
filepath.Join(dir, "run"),
116116
),
117117
}
118-
Configure(opts...)
118+
err = Configure(opts...)
119+
require.NoError(t, err, "unexpected Configure() error")
119120

120121
devices := cache.ListDevices()
121122
if len(tc.devices) == 0 {
@@ -261,7 +262,8 @@ devices:
261262
filepath.Join(dir, "run"),
262263
),
263264
}
264-
Configure(opts...)
265+
err = Configure(opts...)
266+
require.NoError(t, err, "unexpected Configure() error")
265267
} else {
266268
err = updateSpecDirs(dir, update.etc, update.run)
267269
if err != nil {
@@ -395,12 +397,13 @@ devices:
395397
return
396398
}
397399

398-
Configure(
400+
err = Configure(
399401
WithSpecDirs(
400402
filepath.Join(dir, "etc"),
401403
filepath.Join(dir, "run"),
402404
),
403405
)
406+
require.NoError(t, err, "unexpected Configure() error")
404407

405408
unresolved, err := InjectDevices(tc.ociSpec, tc.devices...)
406409
if len(tc.unresolved) != 0 {

0 commit comments

Comments
 (0)