summaryrefslogtreecommitdiff
path: root/pkg/domain/utils/utils.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-03-12 10:49:03 -0700
committerJhon Honce <jhonce@redhat.com>2020-03-18 16:41:12 -0700
commitfbe743501e2a3ea28fe446754b9b12988b4e7a0e (patch)
tree7582c99d828bcbc83b6bb312e253f006ac637734 /pkg/domain/utils/utils.go
parentbd9386ddac4ef6730fbe6ce4104e80f56a48fe43 (diff)
downloadpodman-fbe743501e2a3ea28fe446754b9b12988b4e7a0e.tar.gz
podman-fbe743501e2a3ea28fe446754b9b12988b4e7a0e.tar.bz2
podman-fbe743501e2a3ea28fe446754b9b12988b4e7a0e.zip
V2 podman command
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/domain/utils/utils.go')
-rw-r--r--pkg/domain/utils/utils.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/domain/utils/utils.go b/pkg/domain/utils/utils.go
new file mode 100644
index 000000000..c17769f62
--- /dev/null
+++ b/pkg/domain/utils/utils.go
@@ -0,0 +1,41 @@
+package utils
+
+import (
+ "net/url"
+ "strings"
+
+ jsoniter "github.com/json-iterator/go"
+)
+
+var json = jsoniter.ConfigCompatibleWithStandardLibrary
+
+// DeepCopy does a deep copy of a structure
+// Error checking of parameters delegated to json engine
+var DeepCopy = func(dst interface{}, src interface{}) error {
+ payload, err := json.Marshal(src)
+ if err != nil {
+ return err
+ }
+
+ err = json.Unmarshal(payload, dst)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func ToLibpodFilters(f url.Values) (filters []string) {
+ for k, v := range f {
+ filters = append(filters, k+"="+v[0])
+ }
+ return
+}
+
+func ToUrlValues(f []string) (filters url.Values) {
+ filters = make(url.Values)
+ for _, v := range f {
+ t := strings.SplitN(v, "=", 2)
+ filters.Add(t[0], t[1])
+ }
+ return
+}