configfile: normalize Docker Hub auth key aliases - #7190
configfile: normalize Docker Hub auth key aliases#7190mclean-technology wants to merge 1 commit into
Conversation
Normalize Docker Hub auth credential keys so docker.io, index.docker.io, and https://index.docker.io/v1/ all resolve to the same canonical credential entry. This keeps config-file auths, DOCKER_AUTH_CONFIG, and credential-helper lookups consistent and adds regression tests for the affected alias paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the review. I normalized the Docker Hub auth key handling so the supported aliases resolve to the same canonical credential entry. This keeps auth lookups consistent across config-file entries, Validation:
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| if acKey == authConfigKey { | ||
| for _, candidate := range []string{"docker.io", "index.docker.io", "https://index.docker.io/v1"} { | ||
| if candidate == acKey || candidate == "" { | ||
| continue |
There was a problem hiding this comment.
This is all de-centralizing the logic again; I don't think that's good. The earlier implementation you had kept it central, and for the logout ("delete") case, it picked some of the normalisation
| authConfigs[addr] = types.AuthConfig{ | ||
| normalizedAddr := getAuthConfigKey(addr) | ||
| authConfigs[normalizedAddr] = types.AuthConfig{ | ||
| Username: username, | ||
| Password: password, | ||
| ServerAddress: addr, | ||
| ServerAddress: normalizedAddr, | ||
| } |
There was a problem hiding this comment.
Same here; I don't think we have to account for someone setting a wrong env-var; if it doesn't resolve, they should fix their env-var to use the correct casing.
| switch strings.TrimSpace(domainName) { | ||
| case "docker.io", "index.docker.io", "https://index.docker.io/v1", authConfigKey: | ||
| return authConfigKey | ||
| default: | ||
| return domainName |
There was a problem hiding this comment.
This is now normalising something ... different? And only to lookup the defaults, but not to normalize the other cases? (i.e., getAuthConfigKey("REGISTRY.exAmPLe.COM") returns REGISTRY.exAmPLe.COM as-is?
Summary
Normalize Docker Hub credential keys to a single canonical value so that the supported aliases all resolve to the same authentication entry:
docker.ioindex.docker.iohttps://index.docker.io/v1/This avoids mismatches when credentials are loaded from different sources, including config files,
DOCKER_AUTH_CONFIG, and credential helper resolution.Changes
DOCKER_AUTH_CONFIGValidation
./scripts/with-go-mod.sh go test ./cli/config/..../scripts/with-go-mod.sh golangci-lint run ./cli/config/...