diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-17 17:22:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 17:22:37 +0000 |
commit | a17afa931d1aa73b8657cf26de3b49841837f66d (patch) | |
tree | 8b3e3408eea4fa15320f5c294d96b8e134bf49c4 /cmd/podman/system/prune.go | |
parent | 033336606f8aa9687cbdff5450c691b48d45e8e6 (diff) | |
parent | 86335aa4ae01dadecd36468409d742e68b76925d (diff) | |
download | podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.gz podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.bz2 podman-a17afa931d1aa73b8657cf26de3b49841837f66d.zip |
Merge pull request #8752 from baude/bindings3volumes
misc bindings to podman v3
Diffstat (limited to 'cmd/podman/system/prune.go')
-rw-r--r-- | cmd/podman/system/prune.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index 5ee017581..ea47e271f 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "net/url" "os" "strings" @@ -12,12 +13,13 @@ import ( "github.com/containers/podman/v2/cmd/podman/utils" "github.com/containers/podman/v2/cmd/podman/validate" "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/pkg/errors" "github.com/spf13/cobra" ) var ( - pruneOptions = entities.SystemPruneOptions{} - + pruneOptions = entities.SystemPruneOptions{} + filters []string pruneDescription = fmt.Sprintf(` podman system prune @@ -47,7 +49,7 @@ func init() { flags.BoolVarP(&pruneOptions.All, "all", "a", false, "Remove all unused data") flags.BoolVar(&pruneOptions.Volume, "volumes", false, "Prune volumes") filterFlagName := "filter" - flags.StringArrayVar(&pruneOptions.Filter, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')") + flags.StringArrayVar(&filters, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')") _ = pruneCommand.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone) } @@ -77,6 +79,15 @@ Are you sure you want to continue? [y/N] `, volumeString) } } + pruneOptions.ContainerPruneOptions = entities.ContainerPruneOptions{} + for _, f := range filters { + t := strings.SplitN(f, "=", 2) + pruneOptions.ContainerPruneOptions.Filters = make(url.Values) + if len(t) < 2 { + return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f) + } + pruneOptions.ContainerPruneOptions.Filters.Add(t[0], t[1]) + } // TODO: support for filters in system prune response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions) if err != nil { @@ -100,7 +111,5 @@ Are you sure you want to continue? [y/N] `, volumeString) } } // Print Images prune results - utils.PrintImagePruneResults(response.ImagePruneReport, true) - - return nil + return utils.PrintImagePruneResults(response.ImagePruneReport, true) } |