-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
login: Add message about using PATs #4478
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4478 +/- ##
==========================================
- Coverage 59.39% 58.97% -0.43%
==========================================
Files 288 286 -2
Lines 24782 24779 -3
==========================================
- Hits 14720 14614 -106
- Misses 9175 9278 +103
Partials 887 887 |
cli/command/registry.go
Outdated
@@ -106,7 +106,12 @@ func ConfigureAuth(cli Cli, flUser, flPassword string, authconfig *registrytypes | |||
if flUser = strings.TrimSpace(flUser); flUser == "" { | |||
if isDefaultRegistry { | |||
// if this is a default registry (docker hub), then display the following message. | |||
fmt.Fprintln(cli.Out(), "Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.") | |||
fmt.Fprintln(cli.Out(), "Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.") | |||
if os.Getenv("DOCKER_CLI_HINTS") != "false" { |
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.
0
should also be supported. It feels more natural for an env variable.
How about using strconv.ParseBool
withh fallback to true
(hints enabled by default) if err != nil
?
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.
Maybe we should also handle "no"
, like yaml does? I'm joking, this check comes from compose-cli.
I kinda like only one possible value here
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.
Another nice possibility is to flip the check, have a DOCKER_NO_CLI_HINTS
and only check that the variable is defined.
Examples
Line 33 in 06de1f8
if !i.isTerminal || os.Getenv("NORAW") != "" { Line 25 in 06de1f8
return os.Getenv("DEBUG") != "" cli/cli-plugins/plugin/plugin.go
Line 36 in 06de1f8
if os.Getenv("DOCKER_CLI_PLUGIN_USE_DIAL_STDIO") != "" {
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.
Personally I'd prefer DOCKER_NO_CLI_HINTS
.
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.
DOCKER_DISABLE_CLI_HINTS
would be an option.
I think we came with DOCKER_CLI_HINTS
in a similar fashion as DOCKER_BUILDKIT
; initially that was "opt-in", but the intent was to make that "opt-out" after incubation.
DOCKER_CLI_HINTS
(and DOCKER_BUILDKIT
) is more agnostic w.r.t. it being enable/disable. And can start with "opt-in" (DOCKER_CLI_HINTS=1
) and when it's the default, "opt-out" (DOCKER_CLI_HINTS=0
), or for situations where the config would disable it and you wanted to enable it for a specific call (through env var), as DOCKER_DISABLE_CLI_HINTS=false
is kinda awkward because of the double negative.
w.r.t. accepted values, if we do look at value (beyond "non-empty"), I agree that we should use ParseBool
if the value is non-empty, which would match other env-vars, such as DOCKER_BUILDKIT
;
Lines 164 to 171 in 06de1f8
// use DOCKER_BUILDKIT env var value if set and not empty | |
if v := os.Getenv("DOCKER_BUILDKIT"); v != "" { | |
enabled, err := strconv.ParseBool(v) | |
if err != nil { | |
return false, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value") | |
} | |
return enabled, nil | |
} |
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.
+1 to ParseBool and DOCKER_NO_CLI_HINTS
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.
We already have DOCKER_CLI_HINTS
in the wrapper (see docker/for-mac#6904 for evidence of people building on it); we might have to continue with that out of inertia, or at least propagate any changes we make here back to the Scout hints implementation (cc @eunomie)
78df3b5
to
d73fc86
Compare
Signed-off-by: Djordje Lukic <[email protected]>
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.
LGTM
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.
LGTM; it's beautiful now!
fmt.Fprintln(cli.Out(), patSuggest) | ||
fmt.Fprintln(cli.Out()) |
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.
We probably can't / shouldn't change the existing (old) hint, but perhaps we should use cli.Err()
here (so that it can be redirected)
const patSuggest = "You can log in with your password or a Personal Access " + | ||
"Token (PAT). Using a limited-scope PAT grants better security and is required " + | ||
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/" |
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.
Perhaps use a string-literal for this (back-tick)
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.
Didn’t use them because we don’t want newlines
This comment was marked as spam.
This comment was marked as spam.
I'm going to merge this as-is, given no further discussion around the env var, and the desire to stay consistent (for now) with what was already done in the CLI wrapper for Scout. |
- What I did
Added a hint about using PATs
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)