summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-25 08:20:38 -0400
committerGitHub <noreply@github.com>2021-06-25 08:20:38 -0400
commitb4767817012a3aedaf05dc7a32bd823fcd3776f4 (patch)
tree2fa1c72aaecad072f3ea4b3283fed20e245c071e /cmd/podman
parent2d191968b513d327e39376bf8fadd2b4267d15a2 (diff)
parentf95b0995e521e252af52edaf57a31241d364e3d8 (diff)
downloadpodman-b4767817012a3aedaf05dc7a32bd823fcd3776f4.tar.gz
podman-b4767817012a3aedaf05dc7a32bd823fcd3776f4.tar.bz2
podman-b4767817012a3aedaf05dc7a32bd823fcd3776f4.zip
Merge pull request #10774 from vrothberg/registries
remove `pkg/registries`
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/completion.go4
-rw-r--r--cmd/podman/login.go24
-rw-r--r--cmd/podman/logout.go9
3 files changed, 26 insertions, 11 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index c93f2017c..177d094aa 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -8,11 +8,11 @@ import (
"strings"
"github.com/containers/common/pkg/config"
+ "github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/network"
- "github.com/containers/podman/v3/pkg/registries"
"github.com/containers/podman/v3/pkg/rootless"
systemdDefine "github.com/containers/podman/v3/pkg/systemd/define"
"github.com/containers/podman/v3/pkg/util"
@@ -236,7 +236,7 @@ func getSecrets(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellCom
}
func getRegistries() ([]string, cobra.ShellCompDirective) {
- regs, err := registries.GetRegistries()
+ regs, err := sysregistriesv2.UnqualifiedSearchRegistries(nil)
if err != nil {
cobra.CompErrorln(err.Error())
return nil, cobra.ShellCompDirectiveNoFileComp
diff --git a/cmd/podman/login.go b/cmd/podman/login.go
index 2101e32e2..a8dadf5cd 100644
--- a/cmd/podman/login.go
+++ b/cmd/podman/login.go
@@ -9,7 +9,6 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
- "github.com/containers/podman/v3/pkg/registries"
"github.com/spf13/cobra"
)
@@ -63,12 +62,29 @@ func login(cmd *cobra.Command, args []string) error {
skipTLS = types.NewOptionalBool(!loginOptions.tlsVerify)
}
- sysCtx := types.SystemContext{
+ sysCtx := &types.SystemContext{
AuthFilePath: loginOptions.AuthFile,
DockerCertPath: loginOptions.CertDir,
DockerInsecureSkipTLSVerify: skipTLS,
- SystemRegistriesConfPath: registries.SystemRegistriesConfPath(),
}
+ setRegistriesConfPath(sysCtx)
loginOptions.GetLoginSet = cmd.Flag("get-login").Changed
- return auth.Login(context.Background(), &sysCtx, &loginOptions.LoginOptions, args)
+ return auth.Login(context.Background(), sysCtx, &loginOptions.LoginOptions, args)
+}
+
+// setRegistriesConfPath sets the registries.conf path for the specified context.
+// NOTE: this is a verbatim copy from c/common/libimage which we're not using
+// to prevent leaking c/storage into this file. Maybe this should go into c/image?
+func setRegistriesConfPath(systemContext *types.SystemContext) {
+ if systemContext.SystemRegistriesConfPath != "" {
+ return
+ }
+ if envOverride, ok := os.LookupEnv("CONTAINERS_REGISTRIES_CONF"); ok {
+ systemContext.SystemRegistriesConfPath = envOverride
+ return
+ }
+ if envOverride, ok := os.LookupEnv("REGISTRIES_CONFIG_PATH"); ok {
+ systemContext.SystemRegistriesConfPath = envOverride
+ return
+ }
}
diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go
index 092ad2610..0ee134635 100644
--- a/cmd/podman/logout.go
+++ b/cmd/podman/logout.go
@@ -8,7 +8,6 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
- "github.com/containers/podman/v3/pkg/registries"
"github.com/spf13/cobra"
)
@@ -48,9 +47,9 @@ func init() {
// Implementation of podman-logout.
func logout(cmd *cobra.Command, args []string) error {
- sysCtx := types.SystemContext{
- AuthFilePath: logoutOptions.AuthFile,
- SystemRegistriesConfPath: registries.SystemRegistriesConfPath(),
+ sysCtx := &types.SystemContext{
+ AuthFilePath: logoutOptions.AuthFile,
}
- return auth.Logout(&sysCtx, &logoutOptions, args)
+ setRegistriesConfPath(sysCtx)
+ return auth.Logout(sysCtx, &logoutOptions, args)
}