From a6a3269c4eaa9b6713569533bd10340df58d9b18 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Wed, 17 Apr 2019 13:43:00 -0400 Subject: fix logout message if login only with docker if checkAuth() success but not logged in with podman, assume it's logged in with docker and retrun the message. Signed-off-by: Qi Wang --- cmd/podman/logout.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go index 8abe918b8..ec581a098 100644 --- a/cmd/podman/logout.go +++ b/cmd/podman/logout.go @@ -3,6 +3,7 @@ package main import ( "fmt" + "github.com/containers/image/docker" "github.com/containers/image/pkg/docker/config" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod/image" @@ -66,12 +67,23 @@ func logoutCmd(c *cliconfig.LogoutValues) error { } err := config.RemoveAuthentication(sc, server) - switch err { + switch errors.Cause(err) { case nil: fmt.Printf("Removed login credentials for %s\n", server) return nil case config.ErrNotLoggedIn: - return errors.Errorf("Not logged into %s\n", server) + // username of user logged in to server (if one exists) + userFromAuthFile, passFromAuthFile, err := config.GetAuthentication(sc, server) + if err != nil { + return errors.Wrapf(err, "error reading auth file") + } + islogin := docker.CheckAuth(getContext(), sc, userFromAuthFile, passFromAuthFile, server) + if userFromAuthFile != "" && passFromAuthFile != "" && islogin == nil { + fmt.Printf("Not logged into %s with podman. Existing credentials were established via docker login. Please use docker logout instead.\n", server) + return nil + } + fmt.Printf("Not logged into %s\n", server) + return nil default: return errors.Wrapf(err, "error logging out of %q", server) } -- cgit v1.2.3-54-g00ecf