diff options
author | Baron Lenardson <lenardson.baron@gmail.com> | 2020-12-21 10:35:21 -0600 |
---|---|---|
committer | Baron Lenardson <lenardson.baron@gmail.com> | 2020-12-21 10:55:39 -0600 |
commit | 5923656f321a9ca7b222c81cdb5f3387cc7cd3ad (patch) | |
tree | 47dfe20988b8ebf512ed769f42ed581a15d90b66 /cmd/podman/system/prune.go | |
parent | 5c6b5ef34905f40562b518799c35be8d06694e65 (diff) | |
download | podman-5923656f321a9ca7b222c81cdb5f3387cc7cd3ad.tar.gz podman-5923656f321a9ca7b222c81cdb5f3387cc7cd3ad.tar.bz2 podman-5923656f321a9ca7b222c81cdb5f3387cc7cd3ad.zip |
Add volume filters to system prune
This change was missed in pull/8689. Now that volume pruneing supports
filters system pruneing can pass its filters down to the volume
pruneing. Additionally this change adds tests for the following components
* podman system prune subcommand with `--volumes` & `--filter` options
* apiv2 api tests for `/system/` and `/libpod/system` endpoints
Relates to #8453, #8672
Signed-off-by: Baron Lenardson <lenardson.baron@gmail.com>
Diffstat (limited to 'cmd/podman/system/prune.go')
-rw-r--r-- | cmd/podman/system/prune.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index ea47e271f..a74363684 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -4,7 +4,6 @@ import ( "bufio" "context" "fmt" - "net/url" "os" "strings" @@ -12,8 +11,8 @@ import ( "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/cmd/podman/utils" "github.com/containers/podman/v2/cmd/podman/validate" + lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/domain/entities" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -55,6 +54,8 @@ func init() { } func prune(cmd *cobra.Command, args []string) error { + var err error + // Prompt for confirmation if --force is not set if !force { reader := bufio.NewReader(os.Stdin) @@ -79,16 +80,11 @@ 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]) + pruneOptions.Filters, err = lpfilters.ParseFilterArgumentsIntoFilters(filters) + if err != nil { + return err } - // TODO: support for filters in system prune + response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions) if err != nil { return err |