Skip to content

Commit ef77ab5

Browse files
committed
pkg/cdi: document possible implicit cache refresh.
Update public API documentation to point out a possible implicit cache refresh and how to query any errors encountered during it. Signed-off-by: Krisztian Litkey <[email protected]>
1 parent 6b920fa commit ef77ab5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pkg/cdi/cache.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ func (c *Cache) refreshIfRequired(force bool) (bool, error) {
222222

223223
// InjectDevices injects the given qualified devices to an OCI Spec. It
224224
// returns any unresolvable devices and an error if injection fails for
225-
// any of the devices.
225+
// any of the devices. Might trigger a cache refresh, in which case any
226+
// errors encountered can be obtained using GetErrors().
226227
func (c *Cache) InjectDevices(ociSpec *oci.Spec, devices ...string) ([]string, error) {
227228
var unresolved []string
228229

@@ -335,7 +336,9 @@ func (c *Cache) RemoveSpec(name string) error {
335336
return err
336337
}
337338

338-
// GetDevice returns the cached device for the given qualified name.
339+
// GetDevice returns the cached device for the given qualified name. Might trigger
340+
// a cache refresh, in which case any errors encountered can be obtained using
341+
// GetErrors().
339342
func (c *Cache) GetDevice(device string) *Device {
340343
c.Lock()
341344
defer c.Unlock()
@@ -345,7 +348,8 @@ func (c *Cache) GetDevice(device string) *Device {
345348
return c.devices[device]
346349
}
347350

348-
// ListDevices lists all cached devices by qualified name.
351+
// ListDevices lists all cached devices by qualified name. Might trigger a cache
352+
// refresh, in which case any errors encountered can be obtained using GetErrors().
349353
func (c *Cache) ListDevices() []string {
350354
var devices []string
351355

@@ -362,7 +366,8 @@ func (c *Cache) ListDevices() []string {
362366
return devices
363367
}
364368

365-
// ListVendors lists all vendors known to the cache.
369+
// ListVendors lists all vendors known to the cache. Might trigger a cache refresh,
370+
// in which case any errors encountered can be obtained using GetErrors().
366371
func (c *Cache) ListVendors() []string {
367372
var vendors []string
368373

@@ -379,7 +384,8 @@ func (c *Cache) ListVendors() []string {
379384
return vendors
380385
}
381386

382-
// ListClasses lists all device classes known to the cache.
387+
// ListClasses lists all device classes known to the cache. Might trigger a cache
388+
// refresh, in which case any errors encountered can be obtained using GetErrors().
383389
func (c *Cache) ListClasses() []string {
384390
var (
385391
cmap = map[string]struct{}{}
@@ -404,7 +410,8 @@ func (c *Cache) ListClasses() []string {
404410
return classes
405411
}
406412

407-
// GetVendorSpecs returns all specs for the given vendor.
413+
// GetVendorSpecs returns all specs for the given vendor. Might trigger a cache
414+
// refresh, in which case any errors encountered can be obtained using GetErrors().
408415
func (c *Cache) GetVendorSpecs(vendor string) []*Spec {
409416
c.Lock()
410417
defer c.Unlock()

0 commit comments

Comments
 (0)