Merge pull request #5446 from Random-Liu/fix-auth-config

Fix different registry hosts referencing the same auth config.
This commit is contained in:
Mike Brown 2021-05-04 06:21:02 -05:00 committed by GitHub
commit c1a35232d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -375,9 +375,17 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
} }
} }
// Make a copy of `auth`, so that different authorizers would not reference
// the same auth variable.
auth := auth
if auth == nil && config.Auth != nil { if auth == nil && config.Auth != nil {
auth = toRuntimeAuthConfig(*config.Auth) auth = toRuntimeAuthConfig(*config.Auth)
} }
authorizer := docker.NewDockerAuthorizer(
docker.WithAuthClient(client),
docker.WithAuthCreds(func(host string) (string, string, error) {
return ParseAuth(auth, host)
}))
if u.Path == "" { if u.Path == "" {
u.Path = "/v2" u.Path = "/v2"
@ -385,11 +393,7 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
registries = append(registries, docker.RegistryHost{ registries = append(registries, docker.RegistryHost{
Client: client, Client: client,
Authorizer: docker.NewDockerAuthorizer( Authorizer: authorizer,
docker.WithAuthClient(client),
docker.WithAuthCreds(func(host string) (string, string, error) {
return ParseAuth(auth, host)
})),
Host: u.Host, Host: u.Host,
Scheme: u.Scheme, Scheme: u.Scheme,
Path: u.Path, Path: u.Path,