Merge pull request #11031 from k8s-infra-cherrypick-robot/cherry-pick-10917-to-release/2.0

[release/2.0] fix: set the credentials even if not provided
This commit is contained in:
Derek McGowan 2024-11-19 15:52:59 -08:00 committed by GitHub
commit 6e51f71621
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,6 +133,20 @@ func (c *CRIImageService) PullImage(ctx context.Context, name string, credential
defer inProgressImagePulls.Dec()
startTime := time.Now()
if credentials == nil {
credentials = func(host string) (string, string, error) {
var hostauth *runtime.AuthConfig
config := c.config.Registry.Configs[host]
if config.Auth != nil {
hostauth = toRuntimeAuthConfig(*config.Auth)
}
return ParseAuth(hostauth, host)
}
}
namedRef, err := distribution.ParseDockerRef(name)
if err != nil {
return "", fmt.Errorf("failed to parse image reference %q: %w", name, err)