From 5923656f321a9ca7b222c81cdb5f3387cc7cd3ad Mon Sep 17 00:00:00 2001 From: Baron Lenardson Date: Mon, 21 Dec 2020 10:35:21 -0600 Subject: 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 --- libpod/filters/helpers.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libpod/filters/helpers.go (limited to 'libpod') diff --git a/libpod/filters/helpers.go b/libpod/filters/helpers.go new file mode 100644 index 000000000..859db3a9a --- /dev/null +++ b/libpod/filters/helpers.go @@ -0,0 +1,20 @@ +package lpfilters + +import ( + "net/url" + "strings" + + "github.com/pkg/errors" +) + +func ParseFilterArgumentsIntoFilters(filters []string) (url.Values, error) { + parsedFilters := make(url.Values) + for _, f := range filters { + t := strings.SplitN(f, "=", 2) + if len(t) < 2 { + return parsedFilters, errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f) + } + parsedFilters.Add(t[0], t[1]) + } + return parsedFilters, nil +} -- cgit v1.2.3-54-g00ecf