summaryrefslogtreecommitdiff
path: root/cmd/podman/common
diff options
context:
space:
mode:
authorJakub Guzik <jakubmguzik@gmail.com>2021-05-08 22:47:23 +0200
committerJakub Guzik <jakubmguzik@gmail.com>2021-05-12 08:35:59 +0200
commit3aae34694623cce5f1da4a93c7c1e729c528402c (patch)
tree52b74c6da00bd1f2e8f4b42d7e679730c0096e2f /cmd/podman/common
parent59dd35750931547c66e34e999ab960c90f18f510 (diff)
downloadpodman-3aae34694623cce5f1da4a93c7c1e729c528402c.tar.gz
podman-3aae34694623cce5f1da4a93c7c1e729c528402c.tar.bz2
podman-3aae34694623cce5f1da4a93c7c1e729c528402c.zip
Move filter parsing to common utils
Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
Diffstat (limited to 'cmd/podman/common')
-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