summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-23 10:32:15 +0200
committerGitHub <noreply@github.com>2020-04-23 10:32:15 +0200
commitc71bbffc0f32b4539897249f0f3c1d1398d9f2b4 (patch)
treefdf0f01b0971f98e86f7084b9ffc608eebd91774 /libpod
parentbf1e5b875f365cc42cfd2a88fbe7e577e05a49f7 (diff)
parentbe5605ac4f0a9765c11bbd52ef0a658d2439b372 (diff)
downloadpodman-c71bbffc0f32b4539897249f0f3c1d1398d9f2b4.tar.gz
podman-c71bbffc0f32b4539897249f0f3c1d1398d9f2b4.tar.bz2
podman-c71bbffc0f32b4539897249f0f3c1d1398d9f2b4.zip
Merge pull request #5948 from jwhonce/jira/826
V2 Restore rmi tests
Diffstat (limited to 'libpod')
-rw-r--r--libpod/define/errors.go3
-rw-r--r--libpod/runtime_img.go6
2 files changed, 7 insertions, 2 deletions
diff --git a/libpod/define/errors.go b/libpod/define/errors.go
index 3ba343789..16df2a1cc 100644
--- a/libpod/define/errors.go
+++ b/libpod/define/errors.go
@@ -141,4 +141,7 @@ var (
// ErrConmonOutdated indicates the version of conmon found (whether via the configuration or $PATH)
// is out of date for the current podman version
ErrConmonOutdated = errors.New("outdated conmon version")
+
+ // ErrImageInUse indicates the requested operation failed because the image was in use
+ ErrImageInUse = errors.New("image is being used")
)
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 6ac32878b..919080c42 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -71,7 +71,8 @@ func (r *Runtime) RemoveImage(ctx context.Context, img *image.Image, force bool)
// to and untag it.
repoName, err := img.MatchRepoTag(img.InputName)
if hasChildren && errors.Cause(err) == image.ErrRepoTagNotFound {
- return nil, errors.Errorf("unable to delete %q (cannot be forced) - image has dependent child images", img.ID())
+ return nil, errors.Wrapf(define.ErrImageInUse,
+ "unable to delete %q (cannot be forced) - image has dependent child images", img.ID())
}
if err != nil {
return nil, err
@@ -84,7 +85,8 @@ func (r *Runtime) RemoveImage(ctx context.Context, img *image.Image, force bool)
} else if len(img.Names()) > 1 && img.InputIsID() && !force {
// If the user requests to delete an image by ID and the image has multiple
// reponames and no force is applied, we error out.
- return nil, fmt.Errorf("unable to delete %s (must force) - image is referred to in multiple tags", img.ID())
+ return nil, errors.Wrapf(define.ErrImageInUse,
+ "unable to delete %s (must force) - image is referred to in multiple tags", img.ID())
}
err = img.Remove(ctx, force)
if err != nil && errors.Cause(err) == storage.ErrImageUsedByContainer {