summaryrefslogtreecommitdiff
path: root/cmd/podman/rmi.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-15 10:06:49 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-20 16:20:12 +0000
commit38a1b2f16d210525eafcc845e7a9cce598207113 (patch)
tree5616a12d68ebe55138fbde85f936a6bc90d4c8fd /cmd/podman/rmi.go
parentecfa321288f10b70a59166f93296c77d262317fc (diff)
downloadpodman-38a1b2f16d210525eafcc845e7a9cce598207113.tar.gz
podman-38a1b2f16d210525eafcc845e7a9cce598207113.tar.bz2
podman-38a1b2f16d210525eafcc845e7a9cce598207113.zip
Image library stage 4 - create and commit
Migrate the podman create and commit subcommandis to leverage the images library. I also had to migrate the cmd/ portions of run and rmi. Signed-off-by: baude <bbaude@redhat.com> Closes: #498 Approved by: mheon
Diffstat (limited to 'cmd/podman/rmi.go')
-rw-r--r--cmd/podman/rmi.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go
index f5938ffb9..b38686a87 100644
--- a/cmd/podman/rmi.go
+++ b/cmd/podman/rmi.go
@@ -6,6 +6,7 @@ import (
"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod"
+ "github.com/projectatomic/libpod/libpod/image"
"github.com/urfave/cli"
)
@@ -51,28 +52,37 @@ func rmiCmd(c *cli.Context) error {
return errors.Errorf("when using the --all switch, you may not pass any images names or IDs")
}
- imagesToDelete := args[:]
+ images := args[:]
var lastError error
+ var imagesToDelete []*image.Image
if removeAll {
- localImages, err := runtime.GetImages(&libpod.ImageFilterParams{})
+ imagesToDelete, err = runtime.GetImages(&libpod.ImageFilterParams{})
if err != nil {
return errors.Wrapf(err, "unable to query local images")
}
- for _, image := range localImages {
- imagesToDelete = append(imagesToDelete, image.ID)
+ } else {
+ // Create image.image objects for deletion from user input
+ for _, i := range images {
+ newImage, err := runtime.ImageRuntime().NewFromLocal(i)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ continue
+ }
+ imagesToDelete = append(imagesToDelete, newImage)
}
}
-
- for _, arg := range imagesToDelete {
- image := runtime.NewImage(arg)
- iid, err := image.Remove(c.Bool("force"))
+ if len(imagesToDelete) == 0 {
+ return errors.Errorf("no valid images to delete")
+ }
+ for _, img := range imagesToDelete {
+ err := runtime.RemoveImage(img, c.Bool("force"))
if err != nil {
if lastError != nil {
fmt.Fprintln(os.Stderr, lastError)
}
lastError = err
} else {
- fmt.Println(iid)
+ fmt.Println(img.ID())
}
}
return lastError