cmd/podman/run.go: Error nicely when no image found

When no image is found, display a useful error message. Also, in imageToRef
protect against a nil image being passed.

Resolves: 

Signed-off-by: baude <bbaude@redhat.com>

Closes: 
Approved by: mheon
This commit is contained in:
baude
2018-03-26 18:28:20 -05:00
committed by Atomic Bot
parent a3156da21c
commit 304bf53c28
2 changed files with 6 additions and 0 deletions
cmd/podman
libpod/image

@ -56,6 +56,9 @@ func runCmd(c *cli.Context) error {
rtc := runtime.GetConfig()
newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{})
if err != nil {
return errors.Wrapf(err, "unable to find image")
}
data, err := newImage.Inspect()
if err != nil {

@ -465,6 +465,9 @@ func (i *Image) ToImageRef() (types.Image, error) {
// toImageRef returns an Image Reference type from an image
func (i *Image) toImageRef() (types.Image, error) {
if i == nil {
return nil, errors.Errorf("cannot convert nil image to image reference")
}
if i.imgRef == nil {
ref, err := is.Transport.ParseStoreReference(i.imageruntime.store, "@"+i.ID())
if err != nil {