Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement logout #123

Merged
merged 3 commits into from
Nov 20, 2020
Merged

Implement logout #123

merged 3 commits into from
Nov 20, 2020

Conversation

rumpl
Copy link
Member

@rumpl rumpl commented Nov 18, 2020

- What I did

Implemented the logout command

- How I did it

Call Erase on the credentials store

- How to verify it

$ hub-tool login <USERNAME>
$ hub-tool repo ls
$ hub-tool logout
$ hub-tool repo ls

The last command should tell the user that they need to login.

Copy link
Member

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit otherwise LGTM

if err := store.Erase(); err != nil {
return err
}
fmt.Println(ansi.Info("Logout Succeeded"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use streams elsewhere, I know you don't agree but we should try to be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Djordje Lukic <[email protected]>
@rumpl rumpl force-pushed the feat-logout branch 2 times, most recently from 97b86c0 to 5056803 Compare November 19, 2020 11:25
Signed-off-by: Djordje Lukic <[email protected]>
@@ -47,7 +47,7 @@ func newLoginCmd(streams command.Streams, store credentials.Store, hubClient *hu
if err := login.RunLogin(cmd.Context(), streams, hubClient, store, args[0]); err != nil {
return err
}
fmt.Println(ansi.Info("Login Succeeded"))
fmt.Fprintln(streams.Out(), ansi.Info("Login Succeeded"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering; does this CLI also print a warning when not using a credentials-store?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it does this:

~/dev/hub-tool feat-logout
❯ docker logout
Removing login credentials for https://index.docker.io/v1/

~/dev/hub-tool feat-logout*
❯ docker logout
Removing login credentials for https://index.docker.io/v1/
WARNING: could not erase credentials:
https://index.docker.io/v1/: error erasing credentials - err: exit status 1, out: `error erasing credentials - err: exit status 1, out: `The specified item could not be found in the keychain.``

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to mute the error when you logout but there are no credentials, am happy to put it back if you think this is useful

func newLogoutCmd(streams command.Streams, store credentials.Store) *cobra.Command {
cmd := &cobra.Command{
Use: logoutName + " USERNAME",
Short: "Logout of the Hub",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me, we should probably update the descriptions of these. Effectively, we're not "logging in" or "logging out", but only storing/removing local credentials.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes indeed, will do thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this a little bit more, the fact that we are storing/removing local credentials is an implementation detail (at least it feels that it is). In the end once the user does a hub-tool login they can do a bunch of authenticated calls, once they hub-tool logout they cannot any longer because the tool cannot make any authenticated calls any more. Having a description that says Remove the credentials from the store is far less useful to me than just Logout of the Hub. WDYT?

Copy link
Collaborator

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@silvin-lubecki silvin-lubecki merged commit 2f39b6e into main Nov 20, 2020
@silvin-lubecki silvin-lubecki deleted the feat-logout branch November 20, 2020 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants