diff options
author | umohnani8 <umohnani@redhat.com> | 2017-12-18 21:30:12 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-19 13:21:56 +0000 |
commit | 0a2f426ceb41475cb0832dafc044b9863b2eb39d (patch) | |
tree | 50b0ddd6b2ab24776cc2f0c673617338ba220572 /cmd | |
parent | d43c63aad700460dc582e3a8b7bd9464c094cd22 (diff) | |
download | podman-0a2f426ceb41475cb0832dafc044b9863b2eb39d.tar.gz podman-0a2f426ceb41475cb0832dafc044b9863b2eb39d.tar.bz2 podman-0a2f426ceb41475cb0832dafc044b9863b2eb39d.zip |
rmi doesn't remove all images if an error occurs
Print out the error if unable to remove image due to multiple tags
or due to it being used in a container and continue to remove all
the other images.
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #153
Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/rmi.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index 1b4cb7390..98ecc1883 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os" "github.com/pkg/errors" "github.com/projectatomic/libpod/libpod" @@ -49,7 +50,9 @@ func rmiCmd(c *cli.Context) error { if len(args) > 0 && removeAll { return errors.Errorf("when using the --all switch, you may not pass any images names or IDs") } + imagesToDelete := args[:] + var lastError error if removeAll { localImages, err := runtime.GetImages(&libpod.ImageFilterParams{}) if err != nil { @@ -63,13 +66,21 @@ func rmiCmd(c *cli.Context) error { for _, arg := range imagesToDelete { image, err := runtime.GetImage(arg) if err != nil { - return errors.Wrapf(err, "could not get image %q", arg) + if lastError != nil { + fmt.Fprintln(os.Stderr, lastError) + } + lastError = errors.Wrapf(err, "could not get image %q", arg) + continue } id, err := runtime.RemoveImage(image, c.Bool("force")) if err != nil { - return errors.Wrapf(err, "error removing image %q", id) + if lastError != nil { + fmt.Fprintln(os.Stderr, lastError) + } + lastError = errors.Wrapf(err, "failed to remove image") + } else { + fmt.Println(id) } - fmt.Printf("%s\n", id) } - return nil + return lastError } |