diff options
author | haircommander <pehunt@redhat.com> | 2018-07-13 17:45:55 -0400 |
---|---|---|
committer | haircommander <pehunt@redhat.com> | 2018-07-20 11:46:11 -0400 |
commit | 0fecfeee6398e2db6b7b3fd257645a6ea9aab542 (patch) | |
tree | 0c8bc2bc742ae2001f992c777ab0ac4d46947553 /libpod/image/pull.go | |
parent | ba1871dac033783ab0329c9b3c9113a34a90992f (diff) | |
download | podman-0fecfeee6398e2db6b7b3fd257645a6ea9aab542.tar.gz podman-0fecfeee6398e2db6b7b3fd257645a6ea9aab542.tar.bz2 podman-0fecfeee6398e2db6b7b3fd257645a6ea9aab542.zip |
Podman load/tag/save prepend localhost when no repository is present
Instead of having docker.io/library as its repository. Test included.
Signed-off-by: haircommander <pehunt@redhat.com>
Diffstat (limited to 'libpod/image/pull.go')
-rw-r--r-- | libpod/image/pull.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go index a5a398eb1..2eaa03858 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -46,6 +46,9 @@ var ( AtomicTransport = "atomic" // DefaultTransport is a prefix that we apply to an image name DefaultTransport = DockerTransport + // DefaultLocalRepo is the default local repository for local image operations + // Remote pulls will still use defined registries + DefaultLocalRepo = "localhost" ) type pullStruct struct { @@ -56,6 +59,14 @@ type pullStruct struct { } func (ir *Runtime) getPullStruct(srcRef types.ImageReference, destName string) (*pullStruct, error) { + imgPart, err := decompose(destName) + if err == nil && !imgPart.hasRegistry { + // If the image doesn't have a registry, set it as the default repo + imgPart.registry = DefaultLocalRepo + imgPart.hasRegistry = true + destName = imgPart.assemble() + } + reference := destName if srcRef.DockerReference() != nil { reference = srcRef.DockerReference().String() @@ -149,7 +160,9 @@ func (ir *Runtime) getPullListFromRef(ctx context.Context, srcRef types.ImageRef image := splitArr[1] // remove leading "/" if image[:1] == "/" { - image = image[1:] + // Instead of removing the leading /, set localhost as the registry + // so docker.io isn't prepended, and the path becomes the repository + image = DefaultLocalRepo + image } pullInfo, err := ir.getPullStruct(srcRef, image) if err != nil { |