summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-01-30 10:41:10 +0100
committerGitHub <noreply@github.com>2019-01-30 10:41:10 +0100
commit76019c31f535c6473e5f7d645cf42ca4477e2c33 (patch)
treee2d595054ce380b5074bf0217e0c405ded94178a /cmd/podman
parentad5579e1d9905996612dd135467ee2ee5f62b7d3 (diff)
parent656033ca969477ed809cbed57e752f959899d4f8 (diff)
downloadpodman-76019c31f535c6473e5f7d645cf42ca4477e2c33.tar.gz
podman-76019c31f535c6473e5f7d645cf42ca4477e2c33.tar.bz2
podman-76019c31f535c6473e5f7d645cf42ca4477e2c33.zip
Merge pull request #2205 from baude/prunelikedocker
podman image prune -- implement all flag
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images_prune.go29
-rw-r--r--cmd/podman/varlink/io.podman.varlink2
2 files changed, 17 insertions, 14 deletions
diff --git a/cmd/podman/images_prune.go b/cmd/podman/images_prune.go
index 06879e02d..aef387732 100644
--- a/cmd/podman/images_prune.go
+++ b/cmd/podman/images_prune.go
@@ -2,7 +2,7 @@ package main
import (
"fmt"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@@ -13,33 +13,36 @@ var (
Removes all unnamed images from local storage
`
-
+ pruneImageFlags = []cli.Flag{
+ cli.BoolFlag{
+ Name: "all, a",
+ Usage: "remove all unused images, not just dangling ones",
+ },
+ }
pruneImagesCommand = cli.Command{
Name: "prune",
Usage: "Remove unused images",
Description: pruneImagesDescription,
Action: pruneImagesCmd,
OnUsageError: usageErrorHandler,
+ Flags: pruneImageFlags,
}
)
func pruneImagesCmd(c *cli.Context) error {
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
- pruneImages, err := runtime.ImageRuntime().GetPruneImages()
- if err != nil {
- return err
- }
-
- for _, i := range pruneImages {
- if err := i.Remove(true); err != nil {
- return errors.Wrapf(err, "failed to remove %s", i.ID())
+ // Call prune; if any cids are returned, print them and then
+ // return err in case an error also came up
+ pruneCids, err := runtime.PruneImages(c.Bool("all"))
+ if len(pruneCids) > 0 {
+ for _, cid := range pruneCids {
+ fmt.Println(cid)
}
- fmt.Println(i.ID())
}
- return nil
+ return err
}
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 86c3eb7ff..80f0bbdfe 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -1019,7 +1019,7 @@ method UnmountContainer(name: string, force: bool) -> ()
# ImagesPrune removes all unused images from the local store. Upon successful pruning,
# the IDs of the removed images are returned.
-method ImagesPrune() -> (pruned: []string)
+method ImagesPrune(all: bool) -> (pruned: []string)
# This function is not implemented yet.
method ListContainerPorts(name: string) -> (notimplemented: NotImplemented)