summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-03 20:29:41 +0200
committerGitHub <noreply@github.com>2019-05-03 20:29:41 +0200
commit2658e870d21dc03096740f17fa869463136d3fae (patch)
treeb6d51913fceed5121bedc63a2a18cee2c9165abe /cmd
parentfde0dc2a55b27b24e89100da3c2c9d52044a8208 (diff)
parenta6a3269c4eaa9b6713569533bd10340df58d9b18 (diff)
downloadpodman-2658e870d21dc03096740f17fa869463136d3fae.tar.gz
podman-2658e870d21dc03096740f17fa869463136d3fae.tar.bz2
podman-2658e870d21dc03096740f17fa869463136d3fae.zip
Merge pull request #2971 from QiWang19/logoutcheck
fix logout message if login only with docker
Diffstat (limited to 'cmd')
-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)
}