-
Notifications
You must be signed in to change notification settings - Fork 2.1k
registry: warn of DOCKER_AUTH_CONFIG usage in login and logout
#6163
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
Conversation
Signed-off-by: Alano Terblanche <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6163 +/- ##
==========================================
- Coverage 54.82% 54.78% -0.04%
==========================================
Files 364 365 +1
Lines 30467 30491 +24
==========================================
+ Hits 16703 16706 +3
- Misses 12789 12809 +20
- Partials 975 976 +1 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
Adds a warning if the DOCKER_AUTH_CONFIG environment variable is set when running docker login or docker logout.
- Refactors
PrintNoteinto a more flexibleprintNoteWithOptionsand adds a newPrintWarningmethod. - Renames the
dockerEnvConfigconstant toDockerEnvConfigKeyand updates its references. - Introduces
maybePrintEnvAuthWarningin the registry commands to surface the warning.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/tui/note.go | Extracts printNoteWithOptions, adds withHeader/withMessageColor options, and defines PrintWarning. |
| cli/config/configfile/file.go | Renames dockerEnvConfig to DockerEnvConfigKey and updates environment lookup. |
| cli/command/registry/warning.go | Adds maybePrintEnvAuthWarning to emit the warning when DOCKER_AUTH_CONFIG is set. |
| cli/command/registry/login.go | Calls maybePrintEnvAuthWarning before running login. |
| cli/command/registry/logout.go | Calls maybePrintEnvAuthWarning before running logout. |
Comments suppressed due to low confidence (2)
cli/command/registry/warning.go:13
- There are no unit tests covering
maybePrintEnvAuthWarning. Please add tests to verify the warning only appears whenDOCKER_AUTH_CONFIGis set and is written to stderr.
func maybePrintEnvAuthWarning(out command.Streams) {
cli/command/registry/warning.go:1
- [nitpick] The file
warning.gois very generic. Consider renaming it toenv_auth_warning.goor similar to better reflect that it handlesDOCKER_AUTH_CONFIGwarnings.
package registry
| return err | ||
| } | ||
|
|
||
| maybePrintEnvAuthWarning(dockerCLI) |
Copilot
AI
Jul 7, 2025
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.
The call to maybePrintEnvAuthWarning is passing a command.Cli instead of command.Streams. Either extract and pass the streams (dockerCLI.Streams()) or adjust the helper to accept the CLI interface.
| maybePrintEnvAuthWarning(dockerCLI) | |
| maybePrintEnvAuthWarning(dockerCLI.Streams()) |
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.
FWIW this comment could make sense to be explicit about what we pass.
We could even consider making it accept a stream.Out, but that's a concrete type (I don't think we have an interface for those)
Lines 11 to 14 in 28f19a9
| // Out is an output stream to write normal program output. It implements | |
| // an [io.Writer], with additional utilities for detecting whether a terminal | |
| // is connected, getting the TTY size, and putting the terminal in raw mode. | |
| type Out struct { |
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.
I should probably outline my motivation; we have various places where (out of convenience) we just pass DockerCLI around; there's many places where we don't need a full CLI, but because we do, it's not always clear "what's used". Changing the maybePrintEnvAuthWarning to accept a shallower interface already helps, but explicitly passing only what's needed helps as well to discover places where we only need a subset of the CLI's functionality (and can help reduce the "ripple effect" of some of those.
c5d5e2c to
100160b
Compare
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
we should (separately) continue the discussion on the expected behavior; to some extent having DOCKER_AUTH_CONFIG set resulting in docker login to proceed without any input is a bit surprising. That's related to changes from the past to consider "credentials stored on disk / in credentials helper" to be re-used (I THINK the motivation there may have been to allow the credentials-helper to be responsible for asking for input, but I'd have to dig in history if that was indeed the reason).
To some extend it could make sense to make docker login ignore the env-var, and assume "I want to store new credentials", but that will make more sense once we implemented the "multiple options to try" by changing privilege-funcs that I was considering; see
Signed-off-by: Alano Terblanche <[email protected]>
Signed-off-by: Alano Terblanche <[email protected]>
100160b to
ccd5bd8
Compare
thaJeztah
left a comment
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, thanks!
DOCKER_AUTH_CONFIGtakes precedence overdocker login#6156- What I did
Add a warning when
DOCKER_AUTH_CONFIGis used when runningdocker loginanddocker logout.- How I did it
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)