From be5605ac4f0a9765c11bbd52ef0a658d2439b372 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Wed, 22 Apr 2020 15:29:47 -0700 Subject: V2 Restore rmi tests * Introduced define.ErrImageInUse to assist in determining the exit code without resorting string searches. Signed-off-by: Jhon Honce --- libpod/runtime_img.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libpod/runtime_img.go') 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 { -- cgit v1.2.3-54-g00ecf