fix: set the credentials even if not provided

Fixes #10916

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
Andrey Smirnov 2024-10-29 20:42:02 +04:00 committed by k8s-infra-cherrypick-robot
parent 78795fa068
commit 9860888666

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)