summaryrefslogtreecommitdiff
path: root/pkg/registries
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-06-24 14:35:10 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-06-25 09:56:21 +0200
commitf95b0995e521e252af52edaf57a31241d364e3d8 (patch)
tree438f53d11703722c6712cf1b84c9fe1efdc884d0 /pkg/registries
parentd1f57a07c24a0defc0b0027206fc4454307f64fa (diff)
downloadpodman-f95b0995e521e252af52edaf57a31241d364e3d8.tar.gz
podman-f95b0995e521e252af52edaf57a31241d364e3d8.tar.bz2
podman-f95b0995e521e252af52edaf57a31241d364e3d8.zip
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 <rothberg@redhat.com>
Diffstat (limited to 'pkg/registries')
-rw-r--r--pkg/registries/registries.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go
deleted file mode 100644
index 34c9138e3..000000000
--- a/pkg/registries/registries.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package registries
-
-// TODO: this package should not exist anymore. Users should either use
-// c/image's `sysregistriesv2` package directly OR, even better, we cache a
-// config in libpod's image runtime so we don't need to parse the
-// registries.conf files redundantly.
-
-import (
- "os"
- "path/filepath"
-
- "github.com/containers/image/v5/pkg/sysregistriesv2"
- "github.com/containers/image/v5/types"
- "github.com/containers/podman/v3/pkg/rootless"
- "github.com/pkg/errors"
-)
-
-// userRegistriesFile is the path to the per user registry configuration file.
-var userRegistriesFile = filepath.Join(os.Getenv("HOME"), ".config/containers/registries.conf")
-
-// SystemRegistriesConfPath returns an appropriate value for types.SystemContext.SystemRegistriesConfPath
-// (possibly "", which is not an error), taking into account rootless mode and environment variable overrides.
-//
-// FIXME: This should be centralized in a global SystemContext initializer inherited throughout the code,
-// not haphazardly called throughout the way it is being called now.
-func SystemRegistriesConfPath() string {
- if envOverride, ok := os.LookupEnv("CONTAINERS_REGISTRIES_CONF"); ok {
- return envOverride
- }
- if envOverride, ok := os.LookupEnv("REGISTRIES_CONFIG_PATH"); ok {
- return envOverride
- }
-
- if rootless.IsRootless() {
- if _, err := os.Stat(userRegistriesFile); err == nil {
- return userRegistriesFile
- }
- }
-
- return ""
-}
-
-// GetRegistriesData obtains the list of registries
-func GetRegistriesData() ([]sysregistriesv2.Registry, error) {
- registries, err := sysregistriesv2.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()})
- if err != nil {
- return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
- }
- return registries, nil
-}
-
-// GetRegistries obtains the list of search registries defined in the global registries file.
-func GetRegistries() ([]string, error) {
- return sysregistriesv2.UnqualifiedSearchRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()})
-}
-
-// GetBlockedRegistries obtains the list of blocked registries defined in the global registries file.
-func GetBlockedRegistries() ([]string, error) {
- var blockedRegistries []string
- registries, err := GetRegistriesData()
- if err != nil {
- return nil, err
- }
- for _, reg := range registries {
- if reg.Blocked {
- blockedRegistries = append(blockedRegistries, reg.Prefix)
- }
- }
- return blockedRegistries, nil
-}
-
-// GetInsecureRegistries obtains the list of insecure registries from the global registration file.
-func GetInsecureRegistries() ([]string, error) {
- var insecureRegistries []string
- registries, err := GetRegistriesData()
- if err != nil {
- return nil, err
- }
- for _, reg := range registries {
- if reg.Insecure {
- insecureRegistries = append(insecureRegistries, reg.Prefix)
- }
- }
- return insecureRegistries, nil
-}