Skip to content

Commit

Permalink
try fetch auth for default docker registiry urls
Browse files Browse the repository at this point in the history
  • Loading branch information
taraspos committed Oct 9, 2020
1 parent 9c278ca commit 76fa41b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions core/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func buildPullOptions(image string) (docker.PullImageOptions, docker.AuthConfigu
return docker.PullImageOptions{
Repository: repository,
Registry: registry,
Tag: tag,
Tag: tag,
}, buildAuthConfiguration(registry)
}

Expand All @@ -274,6 +274,20 @@ func buildAuthConfiguration(registry string) docker.AuthConfiguration {
return auth
}

auth, _ = dockercfg.Configs[registry]
if v, ok := dockercfg.Configs[registry]; ok {
return v
}

// try to fetch configs from docker hub default registry urls
// see example here: https://www.projectatomic.io/blog/2016/03/docker-credentials-store/
if registry == "" {
if v, ok := dockercfg.Configs["https://index.docker.io/v2/"]; ok {
return v
}
if v, ok := dockercfg.Configs["https://index.docker.io/v1/"]; ok {
return v
}
}

return auth
}

0 comments on commit 76fa41b

Please sign in to comment.