Skip to content

Commit

Permalink
pull: don't resolve short names on explicit docker:// reference
Browse files Browse the repository at this point in the history
Fixes: containers#581
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
  • Loading branch information
vrothberg committed May 26, 2021
1 parent 64b0f96 commit f109e1a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (r *Runtime) Pull(ctx context.Context, name string, pullPolicy config.PullP
options = &PullOptions{}
}

var possiblyUnqualifiedName string // used for short-name resolution
ref, err := alltransports.ParseImageName(name)
if err != nil {
// If the image clearly refers to a local one, we can look it up directly.
Expand All @@ -74,6 +75,17 @@ func (r *Runtime) Pull(ctx context.Context, name string, pullPolicy config.PullP
return nil, err
}
ref = dockerRef
possiblyUnqualifiedName = name
} else if ref.Transport().Name() == registryTransport.Transport.Name() {
// Normalize the input if we're referring to the docker
// transport directly. That makes sure that a `docker://fedora`
// will resolve directly to `docker.io/library/fedora:latest`
// and not be subject to short-name resolution.
named := ref.DockerReference()
if named == nil {
return nil, errors.New("internal error: unexpected nil reference")
}
possiblyUnqualifiedName = named.String()
}

if options.AllTags && ref.Transport().Name() != registryTransport.Transport.Name() {
Expand All @@ -94,7 +106,7 @@ func (r *Runtime) Pull(ctx context.Context, name string, pullPolicy config.PullP

// DOCKER REGISTRY
case registryTransport.Transport.Name():
pulledImages, pullError = r.copyFromRegistry(ctx, ref, strings.TrimPrefix(name, "docker://"), pullPolicy, options)
pulledImages, pullError = r.copyFromRegistry(ctx, ref, possiblyUnqualifiedName, pullPolicy, options)

// DOCKER ARCHIVE
case dockerArchiveTransport.Transport.Name():
Expand Down

0 comments on commit f109e1a

Please sign in to comment.