Skip to content

Commit

Permalink
pkg/cdi: deprecate Registry and related interfaces.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
  • Loading branch information
klihub committed Mar 1, 2024
1 parent 2c40f2d commit 16506da
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cdi/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
//
// # CDI Registry
//
// Note: the Registry and its related interfaces are deprecated and will
// be removed in a future version. Please use the default cache and its
// related package-level function instead.
//
// The primary interface to interact with CDI devices is the Registry. It
// is essentially a cache of all Specs and devices discovered in standard
// CDI directories on the host. The registry has two main functionality,
Expand Down
35 changes: 35 additions & 0 deletions pkg/cdi/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import (
//
// The most commonly used Registry functions are for refreshing the
// registry and injecting CDI devices into an OCI Spec.
//
// Deprecated: Registry is deprecated and will be removed in a future
// version. Please update your code to use the corresponding package-
// level functions Configure(), Refresh(), InjectDevices(), GetErrors(),
// and GetDefaultCache().
type Registry interface {
RegistryResolver
RegistryRefresher
Expand All @@ -54,6 +59,10 @@ type Registry interface {
//
// GetSpecDirErrors returns any errors related to the configured
// Spec directories.
//
// Deprecated: RegistryRefresher is deprecated and will be removed
// in a future version. Please use the default cache and its related
// package-level functions instead.
type RegistryRefresher interface {
Configure(...Option) error
Refresh() error
Expand All @@ -68,6 +77,10 @@ type RegistryRefresher interface {
// InjectDevices takes an OCI Spec and injects into it a set of
// CDI devices given by qualified name. It returns the names of
// any unresolved devices and an error if injection fails.
//
// Deprecated: RegistryRefresher is deprecated and will be removed
// in a future version. Please use the default cache and its related
// package-level functions instead.
type RegistryResolver interface {
InjectDevices(spec *oci.Spec, device ...string) (unresolved []string, err error)
}
Expand All @@ -79,6 +92,12 @@ type RegistryResolver interface {
//
// ListDevices returns a slice with the names of qualified device
// known. The returned slice is sorted.
//
// Deprecated: RegistryDeviceDB is deprecated and will be removed
// in a future version. Please use the default cache and its related
// package-level functions instead.
// and will be removed in a future version. Please use the default
// cache and its related package-level functions instead.
type RegistryDeviceDB interface {
GetDevice(device string) *Device
ListDevices() []string
Expand All @@ -99,6 +118,10 @@ type RegistryDeviceDB interface {
//
// WriteSpec writes the Spec with the given content and name to the
// last Spec directory.
//
// Deprecated: RegistrySpecDB is deprecated and will be removed
// in a future version. Please use the default cache and its related
// package-level functions instead.
type RegistrySpecDB interface {
ListVendors() []string
ListClasses() []string
Expand All @@ -121,6 +144,10 @@ var (

// GetRegistry returns the CDI registry. If any options are given, those
// are applied to the registry.
//
// Deprecated: GetRegistry is deprecated and will be removed in a future
// version. Please use the default cache and its related package-level
// functions instead.
func GetRegistry(options ...Option) Registry {
initOnce.Do(func() {
reg = &registry{GetDefaultCache()}
Expand All @@ -133,11 +160,19 @@ func GetRegistry(options ...Option) Registry {
}

// DeviceDB returns the registry interface for querying devices.
//
// Deprecated: DeviceDB is deprecated and will be removed in a future
// version. Please use the default cache and its related package-level
// functions instead.
func (r *registry) DeviceDB() RegistryDeviceDB {
return r
}

// SpecDB returns the registry interface for querying Specs.
//
// Deprecated: SpecDB is deprecated and will be removed in a future
// version. Please use the default cache and its related package-level
// functions instead.
func (r *registry) SpecDB() RegistrySpecDB {
return r
}

0 comments on commit 16506da

Please sign in to comment.