-
Notifications
You must be signed in to change notification settings - Fork 154
Use profile information when getting a token using the CLI #855
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package auth | |
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "time" | ||
|
|
||
| "github.com/databricks/cli/libs/auth" | ||
|
|
@@ -21,8 +22,20 @@ func newTokenCommand(persistentAuth *auth.PersistentAuth) *cobra.Command { | |
|
|
||
| cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
| ctx := cmd.Context() | ||
| if persistentAuth.Host == "" { | ||
| configureHost(ctx, persistentAuth, args, 0) | ||
|
|
||
| var profileName string | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would happen if we run the command with host positional argument and profile flag? Like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be ignored. The profile flag is used only to get the host from the config. I can't see any valid use-case of passing both as parameters.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The confusing point here is when there's a mismatch between profile host and host in argument. We either should not allow to provide both at the same time or error out if there's host mismatch
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we throw an error if the url is provided on top of the profile?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say we throw an error when host from profile and host from args do not match. @pietern wdyt?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the value of doing that over simply erroring because both a profile name and a host are specified. Are there valid cases where you specify both? If not we should make these mutually exclusive.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only use the profile to select the host. So currently there is no use case for passing both. I added an error if they are both specified. |
||
| profileFlag := cmd.Flag("profile") | ||
| if profileFlag != nil { | ||
| profileName = profileFlag.Value.String() | ||
| // If a profile is provided we read the host from the .databrickscfg file | ||
| if profileName != "" && len(args) > 0 { | ||
| return errors.New("providing both a profile and a host parameters is not supported") | ||
| } | ||
| } | ||
|
|
||
| err := setHost(ctx, profileName, persistentAuth, args) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer persistentAuth.Close() | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.