Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v28.0.3
Choose a base ref
...
head repository: docker/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v28.0.4
Choose a head ref
  • 5 commits
  • 5 files changed
  • 3 contributors

Commits on Mar 25, 2025

  1. vendor: github.com/docker/docker v28.0.3

    no diff; same commit, but tagged
    
    full diff: moby/moby@330857a...v28.0.3
    
    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Mar 25, 2025
    Copy the full SHA
    d8432cd View commit details
  2. cli/config: update link to current version

    Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    thaJeztah committed Mar 25, 2025
    Copy the full SHA
    ee2f787 View commit details
  3. Revert "cli/command: remove uses of GetAuthConfigKey, ParseRepository…

    …Info"
    
    This reverts commit 79141ce.
    
    Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
    vvoland committed Mar 25, 2025
    Copy the full SHA
    f596202 View commit details
  4. Merge pull request #5964 from vvoland/fix-auth-regressionq

    Revert "cli/command: remove uses of GetAuthConfigKey, ParseRepositoryInfo"
    thaJeztah authored Mar 25, 2025
    Copy the full SHA
    3e699a3 View commit details
  5. Merge pull request #5962 from thaJeztah/bump_docker_28.0.3

    vendor: github.com/docker/docker v28.0.3
    vvoland authored Mar 25, 2025
    Copy the full SHA
    b8034c0 View commit details
Showing with 15 additions and 36 deletions.
  1. +10 −31 cli/command/registry.go
  2. +1 −1 cli/config/config.go
  3. +1 −1 vendor.mod
  4. +2 −2 vendor.sum
  5. +1 −1 vendor/modules.txt
41 changes: 10 additions & 31 deletions cli/command/registry.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/tui"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/registry"
"github.com/morikuni/aec"
"github.com/pkg/errors"
)
@@ -27,22 +28,16 @@ const (
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
)

// authConfigKey is the key used to store credentials for Docker Hub. It is
// a copy of [registry.IndexServer].
//
// [registry.IndexServer]: https://pkg.go.dev/github.com/docker/docker/registry#IndexServer
const authConfigKey = "https:/index.docker.io/v1/"

// RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
// for the given command.
func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) registrytypes.RequestAuthConfig {
configKey := getAuthConfigKey(index.Name)
isDefaultRegistry := configKey == authConfigKey || index.Official
return func(ctx context.Context) (string, error) {
_, _ = fmt.Fprintf(cli.Out(), "\nLogin prior to %s:\n", cmdName)
authConfig, err := GetDefaultAuthConfig(cli.ConfigFile(), true, configKey, isDefaultRegistry)
indexServer := registry.GetAuthConfigKey(index)
isDefaultRegistry := indexServer == registry.IndexServer
authConfig, err := GetDefaultAuthConfig(cli.ConfigFile(), true, indexServer, isDefaultRegistry)
if err != nil {
_, _ = fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", authConfigKey, err)
_, _ = fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", indexServer, err)
}

select {
@@ -51,7 +46,7 @@ func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInf
default:
}

authConfig, err = PromptUserForCredentials(ctx, cli, "", "", authConfig.Username, authConfigKey)
authConfig, err = PromptUserForCredentials(ctx, cli, "", "", authConfig.Username, indexServer)
if err != nil {
return "", err
}
@@ -68,7 +63,7 @@ func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInf
func ResolveAuthConfig(cfg *configfile.ConfigFile, index *registrytypes.IndexInfo) registrytypes.AuthConfig {
configKey := index.Name
if index.Official {
configKey = authConfigKey
configKey = registry.IndexServer
}

a, _ := cfg.GetAuthConfig(configKey)
@@ -137,7 +132,7 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword

argUser = strings.TrimSpace(argUser)
if argUser == "" {
if serverAddress == authConfigKey {
if serverAddress == registry.IndexServer {
// When signing in to the default (Docker Hub) registry, we display
// hints for creating an account, and (if hints are enabled), using
// a token instead of a password.
@@ -230,25 +225,9 @@ func resolveAuthConfigFromImage(cfg *configfile.ConfigFile, image string) (regis
if err != nil {
return registrytypes.AuthConfig{}, err
}
configKey := getAuthConfigKey(reference.Domain(registryRef))
a, err := cfg.GetAuthConfig(configKey)
repoInfo, err := registry.ParseRepositoryInfo(registryRef)
if err != nil {
return registrytypes.AuthConfig{}, err
}
return registrytypes.AuthConfig(a), nil
}

// getAuthConfigKey special-cases using the full index address of the official
// index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
//
// It is similar to [registry.GetAuthConfigKey], but does not require on
// [registrytypes.IndexInfo] as intermediate.
//
// [registry.GetAuthConfigKey]: https://pkg.go.dev/github.com/docker/docker/registry#GetAuthConfigKey
// [registrytypes.IndexInfo]:https://pkg.go.dev/github.com/docker/docker/api/types/registry#IndexInfo
func getAuthConfigKey(domainName string) string {
if domainName == "docker.io" || domainName == "index.docker.io" {
return authConfigKey
}
return domainName
return ResolveAuthConfig(cfg, repoInfo.Index), nil
}
2 changes: 1 addition & 1 deletion cli/config/config.go
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ func resetConfigDir() {
// getHomeDir is a copy of [pkg/homedir.Get] to prevent adding docker/docker
// as dependency for consumers that only need to read the config-file.
//
// [pkg/homedir.Get]: https://pkg.go.dev/github.com/docker/docker@v26.1.4+incompatible/pkg/homedir#Get
// [pkg/homedir.Get]: https://pkg.go.dev/github.com/docker/docker@v28.0.3+incompatible/pkg/homedir#Get
func getHomeDir() string {
home, _ := os.UserHomeDir()
if home == "" && runtime.GOOS != "windows" {
2 changes: 1 addition & 1 deletion vendor.mod
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ require (
github.com/distribution/reference v0.6.0
github.com/docker/cli-docs-tool v0.9.0
github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v28.0.3-0.20250325003005-330857ad0ffb+incompatible
github.com/docker/docker v28.0.3+incompatible
github.com/docker/docker-credential-helpers v0.9.2
github.com/docker/go-connections v0.5.0
github.com/docker/go-units v0.5.0
4 changes: 2 additions & 2 deletions vendor.sum
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ github.com/docker/cli-docs-tool v0.9.0/go.mod h1:ClrwlNW+UioiRyH9GiAOe1o3J/TsY3T
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v28.0.3-0.20250325003005-330857ad0ffb+incompatible h1:V27kSTL5Jh5KdeMbmvyjcpLCztmMqrvUQY3hkxMiVM0=
github.com/docker/docker v28.0.3-0.20250325003005-330857ad0ffb+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v28.0.3+incompatible h1:tH0UhLUB03ApG1dLaYDfaz8zUwOglgJzuUftoDKpDtE=
github.com/docker/docker v28.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.9.2 h1:50JF7ADQiHdAVBRtg/vy883Y4U5+5GmPOBNtUU+X+6A=
github.com/docker/docker-credential-helpers v0.9.2/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ github.com/docker/distribution/registry/client/transport
github.com/docker/distribution/registry/storage/cache
github.com/docker/distribution/registry/storage/cache/memory
github.com/docker/distribution/uuid
# github.com/docker/docker v28.0.3-0.20250325003005-330857ad0ffb+incompatible
# github.com/docker/docker v28.0.3+incompatible
## explicit
github.com/docker/docker/api
github.com/docker/docker/api/types