Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/reg_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type RegistryClient struct {

func ResolveAuthConfig(ctx context.Context, index *registrytypes.IndexInfo) registrytypes.AuthConfig {
cfg := config.LoadDefaultConfigFile(os.Stderr)
a, _ := cfg.GetAuthConfig(index.Name)
a, _ := cfg.GetAuthConfig(registry.GetAuthConfigKey(index))
return registrytypes.AuthConfig(a)
}

Expand Down
21 changes: 16 additions & 5 deletions pkg/compose/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ package compose

import (
"fmt"
"net/http"

"github.com/containerd/containerd/remotes/docker"
"github.com/docker/cli/cli/config/configfile"
"net/http"
)

const (
DefaultDockerRegistryHost = "registry-1.docker.io"
DefaultDockerIndexHost = "https://index.docker.io/v1/"
)

type (
authCredsFunc func(string) (string, string, error)
)

func NewRegistryAuthorizer(cfg *configfile.ConfigFile, client *http.Client) docker.Authorizer {
Expand All @@ -14,12 +24,13 @@ func NewRegistryAuthorizer(cfg *configfile.ConfigFile, client *http.Client) dock
)
}

type (
authCredsFunc func(string) (string, string, error)
)

func getAuthCreds(cfg *configfile.ConfigFile) authCredsFunc {
return func(host string) (string, string, error) {
// containerd code translates "docker.io" into "registry-1.docker.io"
if host == DefaultDockerRegistryHost {
// but docker cli uses "https://index.docker.io/v1/" as the key to store auth config
host = DefaultDockerIndexHost
}
creds, err := cfg.GetAllCredentials()
if err != nil {
return "", "", err
Expand Down