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:
commit
6e51f71621
@ -133,6 +133,20 @@ func (c *CRIImageService) PullImage(ctx context.Context, name string, credential
|
|||||||
defer inProgressImagePulls.Dec()
|
defer inProgressImagePulls.Dec()
|
||||||
startTime := time.Now()
|
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)
|
namedRef, err := distribution.ParseDockerRef(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to parse image reference %q: %w", name, err)
|
return "", fmt.Errorf("failed to parse image reference %q: %w", name, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user