-
Notifications
You must be signed in to change notification settings - Fork 55
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
Refresh login on all remote infra commands #374
Conversation
I wonder if user should be prompted if they want to login when using commands like e.g.
|
Great Q! Yes, in this case we'd want to show them the regular login prompt – otherwise it may be unexpected behavior to just pop open a window. Thoughts? I don't think we have to give them an additional |
internal/cmd/cmd.go
Outdated
func login(registry string, interactive bool) error { | ||
config, err := readConfig() | ||
if err != nil { | ||
config = &Config{Host: registry} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration does not exist so create a new Config
internal/cmd/cmd.go
Outdated
} | ||
|
||
if interactive { | ||
config = &Config{Host: config.Host} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commands wants interactive login so discard all configuration except Host
internal/cmd/cmd.go
Outdated
} | ||
|
||
if config.Host == "" { | ||
return errors.New("Registry host is required") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be unlikely since login
will provide a host while other commands will be reading from Config
internal/cmd/cmd.go
Outdated
@@ -459,7 +474,7 @@ func login(config *Config) error { | |||
} | |||
|
|||
if !proceed { | |||
return nil | |||
return errors.New("Could not continue with login") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to short circuit the login flow in commands like list
, users
, and groups
@@ -755,6 +336,14 @@ func NewRootCmd() (*cobra.Command, error) { | |||
return nil, err | |||
} | |||
|
|||
rootCmd := &cobra.Command{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Waiting for #377 to be merged then I'll rebase on top. |
d84014b
to
05cb702
Compare
This isn't possible right now since the new login will automatically login to the current registry and, if there's a single source, not prompt at all. |
That makes sense! Then this is great since the user is running a command. LGTM! |
If session is expired when user runs
infra list
, start login flow. Once user is logged in, continue with the previous command.Fixes #367