Open
Conversation
andrewsomething
requested changes
Aug 18, 2023
| func RunAuthInit(retrieveUserTokenFunc func() (string, error)) func(c *CmdConfig) error { | ||
| return func(c *CmdConfig) error { | ||
| token := c.getContextAccessToken() | ||
| token := viper.GetString(doctl.ArgAccessToken) |
Member
There was a problem hiding this comment.
Unfortunately this has some unintended consequences. As the top level access-token item in the config file is bound to the flag value, there is no way for us to determine if this is passed on the command line or sourced from the config file for the default context.
So this breaks initializing a new non-default context without passing the flag. If a default context is already configured, it's token just gets used:
$ rm ~/.config/doctl/config.yaml
$ ./builds/doctl auth init
Please authenticate doctl for use with your DigitalOcean account. You can generate a token in the control panel at https://cloud.digitalocean.com/account/api/tokens
❯ Enter your access token: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
Validating token... ✔
$ ./builds/doctl auth init --context test
Using token for context test
Validating token... ✔
I'm not sure if there is a simple solution here. This may need to wait until we can do deeper changes to how contexts work.
jerofasion
approved these changes
Apr 30, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #1394
Before:
After: