diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-28 14:51:18 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-28 16:02:53 -0400 |
commit | 99d3e2e9d72f93399a2d3a5974eea0df6362153f (patch) | |
tree | 3f5f22edc53828c52fc4e58f7305fcca90c293ea /libpod | |
parent | e04e567b96cafae30863c7782f7bc10c55bfb681 (diff) | |
download | podman-99d3e2e9d72f93399a2d3a5974eea0df6362153f.tar.gz podman-99d3e2e9d72f93399a2d3a5974eea0df6362153f.tar.bz2 podman-99d3e2e9d72f93399a2d3a5974eea0df6362153f.zip |
NewFromLocal can return multiple images
If you use additional stores and pull the same image into
writable stores, you can end up with the situation where
you have the same image twice. This causes image exists
to return the wrong error. It should return true in this
situation rather then an error.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/define/errors.go | 3 | ||||
-rw-r--r-- | libpod/image/utils.go | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/libpod/define/errors.go b/libpod/define/errors.go index 627928ef7..300e0d7ca 100644 --- a/libpod/define/errors.go +++ b/libpod/define/errors.go @@ -14,6 +14,9 @@ var ( // ErrNoSuchImage indicates the requested image does not exist ErrNoSuchImage = errors.New("no such image") + // ErrMultipleImages found multiple name and tag matches + ErrMultipleImages = errors.New("found multiple name and tag matches") + // ErrNoSuchTag indicates the requested image tag does not exist ErrNoSuchTag = errors.New("no such tag") diff --git a/libpod/image/utils.go b/libpod/image/utils.go index 2538f429b..7429a7f10 100644 --- a/libpod/image/utils.go +++ b/libpod/image/utils.go @@ -11,6 +11,7 @@ import ( "github.com/containers/image/v5/docker/reference" "github.com/containers/image/v5/signature" "github.com/containers/image/v5/types" + "github.com/containers/podman/v2/libpod/define" "github.com/containers/storage" "github.com/pkg/errors" ) @@ -42,7 +43,7 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er if len(results) == 0 { return &storage.Image{}, errors.Errorf("unable to find a name and tag match for %s in repotags", searchName) } else if len(results) > 1 { - return &storage.Image{}, errors.Errorf("found multiple name and tag matches for %s in repotags", searchName) + return &storage.Image{}, errors.Wrapf(define.ErrMultipleImages, searchName) } return results[0], nil } |