summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-18 06:32:29 -0700
committerGitHub <noreply@github.com>2021-03-18 06:32:29 -0700
commit629183bd7f0073dfcbfa4d611abc62a9c5711dab (patch)
tree812ebb2c5a6685f1f333ec960365e97b4e91457f /pkg/util
parent77b3a2df645f2548f7bd2da85bbdb17e4de98310 (diff)
parent8ea02d0b6033b6ffdc68d38f3276410f4e2e8eb9 (diff)
downloadpodman-629183bd7f0073dfcbfa4d611abc62a9c5711dab.tar.gz
podman-629183bd7f0073dfcbfa4d611abc62a9c5711dab.tar.bz2
podman-629183bd7f0073dfcbfa4d611abc62a9c5711dab.zip
Merge pull request #9710 from jmguzik/network-prune-filters-http-api
Network prune filters for http api (compat and libpod)
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/filters.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/util/filters.go b/pkg/util/filters.go
new file mode 100644
index 000000000..bf16f89e3
--- /dev/null
+++ b/pkg/util/filters.go
@@ -0,0 +1,25 @@
+package util
+
+import (
+ "time"
+
+ "github.com/containers/podman/v3/pkg/timetype"
+ "github.com/pkg/errors"
+)
+
+// ComputeUntilTimestamp extracts unitil timestamp from filters
+func ComputeUntilTimestamp(filter string, filterValues []string) (time.Time, error) {
+ invalid := time.Time{}
+ if len(filterValues) != 1 {
+ return invalid, errors.Errorf("specify exactly one timestamp for %s", filter)
+ }
+ ts, err := timetype.GetTimestamp(filterValues[0], time.Now())
+ if err != nil {
+ return invalid, err
+ }
+ seconds, nanoseconds, err := timetype.ParseTimestamps(ts, 0)
+ if err != nil {
+ return invalid, err
+ }
+ return time.Unix(seconds, nanoseconds), nil
+}