diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-12-18 12:27:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 12:27:29 -0800 |
commit | 9b6a70f6c9680ab72f8a5d0685b4bd68222c780c (patch) | |
tree | 728634b6efd609ac37c0fd79dfc12eb980e84160 | |
parent | 08eeef8a8531568a4b652761c71ad6604902eddc (diff) | |
parent | d5647fe053f2fdd97118c6aebfb1e467bdbf3ed3 (diff) | |
download | podman-9b6a70f6c9680ab72f8a5d0685b4bd68222c780c.tar.gz podman-9b6a70f6c9680ab72f8a5d0685b4bd68222c780c.tar.bz2 podman-9b6a70f6c9680ab72f8a5d0685b4bd68222c780c.zip |
Merge pull request #1935 from deuscapturus/master
add getlogin command
-rw-r--r-- | cmd/podman/login.go | 19 | ||||
-rw-r--r-- | completions/bash/podman | 1 | ||||
-rw-r--r-- | docs/podman-login.1.md | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/cmd/podman/login.go b/cmd/podman/login.go index cfdd8005b..4452651f8 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -34,6 +34,10 @@ var ( Usage: "Pathname of a directory containing TLS certificates and keys used to connect to the registry", }, cli.BoolTFlag{ + Name: "get-login", + Usage: "Return the current login user for the registry", + }, + cli.BoolTFlag{ Name: "tls-verify", Usage: "Require HTTPS and verify certificates when contacting registries (default: true)", }, @@ -65,6 +69,21 @@ func loginCmd(c *cli.Context) error { sc := common.GetSystemContext("", authfile, false) + if c.IsSet("get-login") { + user, err := config.GetUserLoggedIn(sc, server) + + if err != nil { + return errors.Wrapf(err, "unable to check for login user") + } + + if user == "" { + return errors.Errorf("not logged into %s", server) + } + + fmt.Printf("%s\n", user) + return nil + } + // username of user logged in to server (if one exists) userFromAuthFile, passFromAuthFile, err := config.GetAuthentication(sc, server) if err != nil { diff --git a/completions/bash/podman b/completions/bash/podman index 9a8adb502..4702ae0e0 100644 --- a/completions/bash/podman +++ b/completions/bash/podman @@ -2217,6 +2217,7 @@ _podman_login() { --password -p --authfile + --get-login " local boolean_options=" --help diff --git a/docs/podman-login.1.md b/docs/podman-login.1.md index 7c033d7c5..e72d1deca 100644 --- a/docs/podman-login.1.md +++ b/docs/podman-login.1.md @@ -36,6 +36,10 @@ Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` +**--get-login** + +Return the logged-in user for the registry. Return error if no login is found. + **--cert-dir** *path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. |