Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/cdi: deprecate Registry and related interfaces. #195

Merged
merged 1 commit into from
Mar 5, 2024
Merged
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
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
}