summaryrefslogtreecommitdiff
path: root/cmd/podman/common/util.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-05-14 13:12:40 -0400
committerGitHub <noreply@github.com>2021-05-14 13:12:40 -0400
commitfabaa256676d3cfb611f89922ccaf3405718a6f0 (patch)
tree82648373f876b243f5c513fa74934940d1b95811 /cmd/podman/common/util.go
parentd05cc0a04a0f5c401624de249505bd160231e2ff (diff)
parent5e6405334c3d0422b5ec7cd09ef9c58d8f558dba (diff)
downloadpodman-fabaa256676d3cfb611f89922ccaf3405718a6f0.tar.gz
podman-fabaa256676d3cfb611f89922ccaf3405718a6f0.tar.bz2
podman-fabaa256676d3cfb611f89922ccaf3405718a6f0.zip
Merge pull request #10254 from jmguzik/prune-filter-cli
Add support for cli network prune --filter flag
Diffstat (limited to 'cmd/podman/common/util.go')
-rw-r--r--cmd/podman/common/util.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/podman/common/util.go b/cmd/podman/common/util.go
index 2a8b2040c..afee55914 100644
--- a/cmd/podman/common/util.go
+++ b/cmd/podman/common/util.go
@@ -35,6 +35,21 @@ func ReadPodIDFiles(files []string) ([]string, error) {
return ids, nil
}
+// ParseFilters transforms one filter format to another and validates input
+func ParseFilters(filter []string) (map[string][]string, error) {
+ // TODO Remove once filter refactor is finished and url.Values done.
+ filters := map[string][]string{}
+ for _, f := range filter {
+ t := strings.SplitN(f, "=", 2)
+ filters = make(map[string][]string)
+ if len(t) < 2 {
+ return map[string][]string{}, errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
+ }
+ filters[t[0]] = append(filters[t[0]], t[1])
+ }
+ return filters, nil
+}
+
// createExpose parses user-provided exposed port definitions and converts them
// into SpecGen format.
// TODO: The SpecGen format should really handle ranges more sanely - we could