From 0eda60957d593411a144371bb4903c7a74307a59 Mon Sep 17 00:00:00 2001 From: baude Date: Tue, 29 May 2018 11:32:41 -0500 Subject: 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 Closes: #841 Approved by: rhatdan --- libpod/image/pull.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'libpod/image/pull.go') 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 +} -- cgit v1.2.3-54-g00ecf