Skip to content

Commit

Permalink
fix registry auth regression (#97)
Browse files Browse the repository at this point in the history
introduced with commit: c30d664

Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com>
  • Loading branch information
jonasagx committed Feb 1, 2022
1 parent c30d664 commit f162f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/image/oci/registry_provider.go
Expand Up @@ -78,13 +78,6 @@ func prepareReferenceOptions(registryOptions *image.RegistryOptions) []name.Opti
}

func prepareRemoteOptions(ref name.Reference, registryOptions *image.RegistryOptions) (opts []remote.Option) {
if registryOptions == nil {
// use the Keychain specified from a docker config file.
log.Debugf("no registry credentials configured, using the default keychain")
opts = append(opts, remote.WithAuthFromKeychain(authn.DefaultKeychain))
return
}

if registryOptions.InsecureSkipTLSVerify {
t := &http.Transport{
// nolint: gosec
Expand All @@ -98,6 +91,10 @@ func prepareRemoteOptions(ref name.Reference, registryOptions *image.RegistryOpt
authenticator := registryOptions.Authenticator(ref.Context().RegistryStr())
if authenticator != nil {
opts = append(opts, remote.WithAuth(authenticator))
} else {
// use the Keychain specified from a docker config file.
log.Debugf("no registry credentials configured, using the default keychain")
opts = append(opts, remote.WithAuthFromKeychain(authn.DefaultKeychain))
}

return
Expand Down
6 changes: 6 additions & 0 deletions pkg/image/source_test.go
Expand Up @@ -21,6 +21,12 @@ func TestDetectSource(t *testing.T) {
tarPath string
tarPaths []string
}{
{
name: "podman-engine",
input: "podman:something:latest",
source: PodmanDaemonSource,
expectedLocation: "something:latest",
},
{
name: "docker-archive",
input: "docker-archive:a/place.tar",
Expand Down

0 comments on commit f162f1e

Please sign in to comment.