summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2019-04-17 13:43:00 -0400
committerQi Wang <qiwan@redhat.com>2019-05-03 12:52:19 -0400
commita6a3269c4eaa9b6713569533bd10340df58d9b18 (patch)
treecbd1ccce8c860782f30a3cbe74ddd03087a5ead6 /cmd/podman
parent6bcbb88715fd9cab45eb668bba5ba83228e16883 (diff)
downloadpodman-a6a3269c4eaa9b6713569533bd10340df58d9b18.tar.gz
podman-a6a3269c4eaa9b6713569533bd10340df58d9b18.tar.bz2
podman-a6a3269c4eaa9b6713569533bd10340df58d9b18.zip
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 <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/logout.go16
1 files changed, 14 insertions, 2 deletions
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)
}