summaryrefslogtreecommitdiff
path: root/libpod/image/image.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-09-26 13:19:45 -0500
committerbaude <bbaude@redhat.com>2018-09-28 12:48:54 -0500
commita931c441043cfc2f03be1d8b92dc5b31b2d2ca4b (patch)
treef1df3583f8799b0adf8a32ee58d30239d89247a2 /libpod/image/image.go
parentca8469aace64d71fdb1849607d8227c31a3cf4da (diff)
downloadpodman-a931c441043cfc2f03be1d8b92dc5b31b2d2ca4b.tar.gz
podman-a931c441043cfc2f03be1d8b92dc5b31b2d2ca4b.tar.bz2
podman-a931c441043cfc2f03be1d8b92dc5b31b2d2ca4b.zip
run complex image names with short names
In cases where the image name is more complex like: quay/baude/alpine_nginx:latest and is not from the docker registry, we need to be able to run the image by its shortname such as baude/alpine_nginx. The same goes when the image is not from a registry but instead has the localhost repository. This resolves buildah issue #1034 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r--libpod/image/image.go27
1 files changed, 7 insertions, 20 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 2c70c6316..197a83dc1 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -239,6 +239,7 @@ func (i *Image) getLocalImage() (*storage.Image, error) {
if err != nil {
return nil, err
}
+
// the inputname isn't tagged, so we assume latest and try again
if !decomposedImage.isTagged {
taggedName = fmt.Sprintf("%s:latest", i.InputName)
@@ -247,15 +248,14 @@ func (i *Image) getLocalImage() (*storage.Image, error) {
return img.image, nil
}
}
- hasReg, err := i.hasRegistry()
- if err != nil {
- return nil, errors.Wrapf(err, imageError)
- }
- // if the input name has a registry in it, the image isnt here
- if hasReg {
+ // The image has a registry name in it and we made sure we looked for it locally
+ // with a tag. It cannot be local.
+ if decomposedImage.hasRegistry {
return nil, errors.Errorf("%s", imageError)
+
}
+
// if the image is saved with the repository localhost, searching with localhost prepended is necessary
// We don't need to strip the sha because we have already determined it is not an ID
img, err = i.imageruntime.getImage(fmt.Sprintf("%s/%s", DefaultLocalRegistry, i.InputName))
@@ -274,21 +274,8 @@ func (i *Image) getLocalImage() (*storage.Image, error) {
if err == nil {
return repoImage, nil
}
- return nil, errors.Wrapf(err, imageError)
-}
-// hasRegistry returns a bool/err response if the image has a registry in its
-// name
-func (i *Image) hasRegistry() (bool, error) {
- imgRef, err := reference.Parse(i.InputName)
- if err != nil {
- return false, err
- }
- registry := reference.Domain(imgRef.(reference.Named))
- if registry != "" {
- return true, nil
- }
- return false, nil
+ return nil, errors.Wrapf(err, imageError)
}
// ID returns the image ID as a string