From 8b0f137b9f446415ca2a6504e4e33fad1c6cabee Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Tue, 23 Jan 2024 19:10:38 +0200 Subject: [PATCH] pkg/cdi: make registry use the default cache. Make the registry use the default cache. Add a documentation note about future plans to obsolete and eventually remove the registry interface. Don't mark the registry obsoleted yet. Signed-off-by: Krisztian Litkey --- pkg/cdi/doc.go | 4 +++- pkg/cdi/registry.go | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/cdi/doc.go b/pkg/cdi/doc.go index 189512f..f9caa76 100644 --- a/pkg/cdi/doc.go +++ b/pkg/cdi/doc.go @@ -35,7 +35,9 @@ // available and instantiated the first time it is referenced directly // or indirectly. The most frequently used cache functions are available // as identically named package level functions which opertate on the -// default cache instance. +// default cache instance. Moreover, the registry also operates on the +// same default cache. We plan to deprecate the registry and eventually +// remove it in a future release. // // # CDI Registry // diff --git a/pkg/cdi/registry.go b/pkg/cdi/registry.go index 1f65727..40e227c 100644 --- a/pkg/cdi/registry.go +++ b/pkg/cdi/registry.go @@ -122,15 +122,12 @@ var ( // GetRegistry returns the CDI registry. If any options are given, those // are applied to the registry. func GetRegistry(options ...Option) Registry { - var new bool initOnce.Do(func() { - reg = ®istry{newCache(options...)} - new = true + reg = ®istry{GetDefaultCache()} }) - if !new && len(options) > 0 { + if len(options) > 0 { // We don't care about errors here _ = reg.Configure(options...) - _ = reg.Refresh() } return reg }