summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-22 21:56:12 +0100
committerGitHub <noreply@github.com>2019-11-22 21:56:12 +0100
commitef240f4cd0fd3bf45f79522eb0cc3aad228e32ac (patch)
tree10bdcd842996eba5a981ff0be296f270bee40346 /cmd
parent35605c02fd9a83f09c61323942243e1a9cf1d4f1 (diff)
parentc7d911e77633a0990a79d05ec3fdc1e04b0fbde1 (diff)
downloadpodman-ef240f4cd0fd3bf45f79522eb0cc3aad228e32ac.tar.gz
podman-ef240f4cd0fd3bf45f79522eb0cc3aad228e32ac.tar.bz2
podman-ef240f4cd0fd3bf45f79522eb0cc3aad228e32ac.zip
Merge pull request #4512 from kunalkushwaha/prune-filter
image prune command fixed as per docker image prune.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/cliconfig/config.go4
-rw-r--r--cmd/podman/images_prune.go20
-rw-r--r--cmd/podman/system_prune.go3
-rw-r--r--cmd/podman/varlink/io.podman.varlink2
4 files changed, 25 insertions, 4 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index 541b2e05d..745f49651 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -175,7 +175,9 @@ type HistoryValues struct {
}
type PruneImagesValues struct {
PodmanCommand
- All bool
+ All bool
+ Force bool
+ Filter []string
}
type PruneContainersValues struct {
diff --git a/cmd/podman/images_prune.go b/cmd/podman/images_prune.go
index 5745edd6b..2b498f83d 100644
--- a/cmd/podman/images_prune.go
+++ b/cmd/podman/images_prune.go
@@ -1,7 +1,10 @@
package main
import (
+ "bufio"
"fmt"
+ "os"
+ "strings"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/pkg/adapter"
@@ -34,9 +37,24 @@ func init() {
pruneImagesCommand.SetUsageTemplate(UsageTemplate())
flags := pruneImagesCommand.Flags()
flags.BoolVarP(&pruneImagesCommand.All, "all", "a", false, "Remove all unused images, not just dangling ones")
+ flags.BoolVarP(&pruneImagesCommand.Force, "force", "f", false, "Do not prompt for confirmation")
+ flags.StringArrayVar(&pruneImagesCommand.Filter, "filter", []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
}
func pruneImagesCmd(c *cliconfig.PruneImagesValues) error {
+ if !c.Force {
+ reader := bufio.NewReader(os.Stdin)
+ fmt.Printf(`
+WARNING! This will remove all dangling images.
+Are you sure you want to continue? [y/N] `)
+ ans, err := reader.ReadString('\n')
+ if err != nil {
+ return errors.Wrapf(err, "error reading input")
+ }
+ if strings.ToLower(ans)[0] != 'y' {
+ return nil
+ }
+ }
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
@@ -45,7 +63,7 @@ func pruneImagesCmd(c *cliconfig.PruneImagesValues) error {
// Call prune; if any cids are returned, print them and then
// return err in case an error also came up
- pruneCids, err := runtime.PruneImages(getContext(), c.All)
+ pruneCids, err := runtime.PruneImages(getContext(), c.All, c.Filter)
if len(pruneCids) > 0 {
for _, cid := range pruneCids {
fmt.Println(cid)
diff --git a/cmd/podman/system_prune.go b/cmd/podman/system_prune.go
index b499d8dd2..c4d76b2dd 100644
--- a/cmd/podman/system_prune.go
+++ b/cmd/podman/system_prune.go
@@ -117,7 +117,8 @@ Are you sure you want to continue? [y/N] `, volumeString)
// Call prune; if any cids are returned, print them and then
// return err in case an error also came up
- pruneCids, err := runtime.PruneImages(ctx, c.All)
+ // TODO: support for filters in system prune
+ pruneCids, err := runtime.PruneImages(ctx, c.All, []string{})
if len(pruneCids) > 0 {
fmt.Println("Deleted Images")
for _, cid := range pruneCids {
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index f9339fccb..4f810dd53 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -1217,7 +1217,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(all: bool) -> (pruned: []string)
+method ImagesPrune(all: bool, filter: []string) -> (pruned: []string)
# This function is not implemented yet.
# method ListContainerPorts(name: string) -> (notimplemented: NotImplemented)