From f95b0995e521e252af52edaf57a31241d364e3d8 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 24 Jun 2021 14:35:10 +0200 Subject: remove `pkg/registries` Pull the trigger on the `pkg/registries` package which acted as a proxy for `c/image/pkg/sysregistriesv2`. Callers should be using the packages from c/image directly, if needed at all. Also make use of libimage's SystemContext() method which returns a copy of a system context, further reducing the risk of unintentionally altering global data. [NO TESTS NEEDED] Signed-off-by: Valentin Rothberg --- libpod/runtime.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'libpod/runtime.go') diff --git a/libpod/runtime.go b/libpod/runtime.go index f53789e89..d31d00ae4 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -29,7 +29,6 @@ import ( "github.com/containers/podman/v3/libpod/plugin" "github.com/containers/podman/v3/libpod/shutdown" "github.com/containers/podman/v3/pkg/cgroups" - "github.com/containers/podman/v3/pkg/registries" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/util" "github.com/containers/storage" @@ -932,7 +931,9 @@ func (r *Runtime) LibimageRuntime() *libimage.Runtime { // SystemContext returns the imagecontext func (r *Runtime) SystemContext() *types.SystemContext { - return r.imageContext + // Return the context from the libimage runtime. libimage is sensitive + // to a number of env vars. + return r.libimageRuntime.SystemContext() } // GetOCIRuntimePath retrieves the path of the default OCI runtime. @@ -1042,9 +1043,9 @@ func (r *Runtime) Reload() error { if err := r.reloadStorageConf(); err != nil { return err } - if err := reloadRegistriesConf(); err != nil { - return err - } + // Invalidate the registries.conf cache. The next invocation will + // reload all data. + sysregistriesv2.InvalidateCache() return nil } @@ -1059,17 +1060,6 @@ func (r *Runtime) reloadContainersConf() error { return nil } -// reloadRegistries reloads the registries.conf -func reloadRegistriesConf() error { - sysregistriesv2.InvalidateCache() - registries, err := sysregistriesv2.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: registries.SystemRegistriesConfPath()}) - if err != nil { - return err - } - logrus.Infof("applied new registry configuration: %+v", registries) - return nil -} - // reloadStorageConf reloads the storage.conf func (r *Runtime) reloadStorageConf() error { configFile, err := storage.DefaultConfigFile(rootless.IsRootless()) -- cgit v1.2.3-54-g00ecf