summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-05-29 11:32:41 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-31 22:07:15 +0000
commit0eda60957d593411a144371bb4903c7a74307a59 (patch)
treeac63650c547480148eb7e63ecff47d721b50e732 /libpod/image
parent81d6f082f36940f72c8a1961ac1150d7e63e415f (diff)
downloadpodman-0eda60957d593411a144371bb4903c7a74307a59.tar.gz
podman-0eda60957d593411a144371bb4903c7a74307a59.tar.bz2
podman-0eda60957d593411a144371bb4903c7a74307a59.zip
fix panic with podman pull
when there are no registries configured for the system and the user provided a short image name, we panic'd due a logic bug in recent image pull changes. Signed-off-by: baude <bbaude@redhat.com> Closes: #841 Approved by: rhatdan
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/pull.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index cd915cb47..48513509d 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -225,7 +225,23 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
images = append(images, imageInfo.image)
}
}
- return images, errors.Wrapf(err, "error pulling image from")
+ // If no image was found, we should handle. Lets be nicer to the user and see if we can figure out why.
+ if len(images) == 0 {
+ registryPath := sysregistries.RegistriesConfPath(&types.SystemContext{})
+ searchRegistries, err := registries.GetRegistries()
+ if err != nil {
+ return nil, err
+ }
+ hasRegistryInName, err := i.hasRegistry()
+ if err != nil {
+ return nil, err
+ }
+ if !hasRegistryInName && len(searchRegistries) == 0 {
+ return nil, errors.Errorf("image name provided is a short name and no search registries are defined in %s.", registryPath)
+ }
+ return nil, errors.Errorf("unable to find image in the registries defined in %q", registryPath)
+ }
+ return images, nil
}
// createNamesToPull looks at a decomposed image and determines the possible
@@ -281,3 +297,13 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) {
return pullNames, nil
}
+
+// isShortName returns a bool response if the input image name has a registry
+// name in it or not
+func (i *Image) isShortName() (bool, error) {
+ decomposedImage, err := decompose(i.InputName)
+ if err != nil {
+ return false, err
+ }
+ return decomposedImage.hasRegistry, nil
+}