From f162f1e96f45df97022f0d1e9c5b4dadeef97ef3 Mon Sep 17 00:00:00 2001 From: Jonas Xavier Date: Tue, 1 Feb 2022 11:05:59 -0800 Subject: [PATCH] fix registry auth regression (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit introduced with commit: c30d664f2d826936fe54d3ba5fca015b467098e0 Signed-off-by: Jonas Galvão Xavier --- pkg/image/oci/registry_provider.go | 11 ++++------- pkg/image/source_test.go | 6 ++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/image/oci/registry_provider.go b/pkg/image/oci/registry_provider.go index 99054635..55b1b4f3 100644 --- a/pkg/image/oci/registry_provider.go +++ b/pkg/image/oci/registry_provider.go @@ -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 @@ -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 diff --git a/pkg/image/source_test.go b/pkg/image/source_test.go index 7e8f6282..5cb828ea 100644 --- a/pkg/image/source_test.go +++ b/pkg/image/source_test.go @@ -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",