diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-08 22:06:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-08 22:06:34 +0100 |
commit | f456ce90f966f2eefdfc27ca83541ceacc4a298d (patch) | |
tree | 24f39eb6404de474cb2e2d41acc2a3ace8410ce5 /cmd/podman/logout.go | |
parent | 651d6ebe5274a892ce64819bb007080895f98321 (diff) | |
parent | d7c0f968ca60994306c8c76cd8e4e0a677fe9ada (diff) | |
download | podman-f456ce90f966f2eefdfc27ca83541ceacc4a298d.tar.gz podman-f456ce90f966f2eefdfc27ca83541ceacc4a298d.tar.bz2 podman-f456ce90f966f2eefdfc27ca83541ceacc4a298d.zip |
Merge pull request #4337 from QiWang19/check_auth_path
fix bug check nonexist authfile
Diffstat (limited to 'cmd/podman/logout.go')
-rw-r--r-- | cmd/podman/logout.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go index ef3452afe..4a113b1d0 100644 --- a/cmd/podman/logout.go +++ b/cmd/podman/logout.go @@ -3,11 +3,11 @@ package main import ( "fmt" + buildahcli "github.com/containers/buildah/pkg/cli" "github.com/containers/image/v5/docker" "github.com/containers/image/v5/pkg/docker/config" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" - "github.com/containers/libpod/libpod/image" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -40,7 +40,7 @@ func init() { logoutCommand.SetUsageTemplate(UsageTemplate()) flags := logoutCommand.Flags() flags.BoolVarP(&logoutCommand.All, "all", "a", false, "Remove the cached credentials for all registries in the auth file") - flags.StringVar(&logoutCommand.Authfile, "authfile", shared.GetAuthFile(""), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override") + flags.StringVar(&logoutCommand.Authfile, "authfile", buildahcli.GetDefaultAuthFile(), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override") markFlagHiddenForRemoteClient("authfile", flags) } @@ -59,7 +59,10 @@ func logoutCmd(c *cliconfig.LogoutValues) error { server = scrubServer(args[0]) } - sc := image.GetSystemContext("", c.Authfile, false) + sc, err := shared.GetSystemContext(c.Authfile) + if err != nil { + return err + } if c.All { if err := config.RemoveAllAuthentication(sc); err != nil { @@ -69,7 +72,7 @@ func logoutCmd(c *cliconfig.LogoutValues) error { return nil } - err := config.RemoveAuthentication(sc, server) + err = config.RemoveAuthentication(sc, server) switch errors.Cause(err) { case nil: fmt.Printf("Removed login credentials for %s\n", server) |