summaryrefslogtreecommitdiff
path: root/pkg/bindings/util
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-02-02 18:52:32 +0100
committerMatej Vasek <mvasek@redhat.com>2021-02-02 19:49:38 +0100
commit5a746c08f753c2e1227fefdbf9527cddba00e2fa (patch)
treede10e5ff39588f663c1099f278ae012296c3970b /pkg/bindings/util
parentd66a18cb11688060a3ef737dd05758398279f053 (diff)
downloadpodman-5a746c08f753c2e1227fefdbf9527cddba00e2fa.tar.gz
podman-5a746c08f753c2e1227fefdbf9527cddba00e2fa.tar.bz2
podman-5a746c08f753c2e1227fefdbf9527cddba00e2fa.zip
[NO TESTS NEEDED] Improve generator
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'pkg/bindings/util')
-rw-r--r--pkg/bindings/util/util.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/bindings/util/util.go b/pkg/bindings/util/util.go
new file mode 100644
index 000000000..403846355
--- /dev/null
+++ b/pkg/bindings/util/util.go
@@ -0,0 +1,30 @@
+package util
+
+import (
+ "reflect"
+ "strconv"
+)
+
+func IsSimpleType(f reflect.Value) bool {
+ switch f.Kind() {
+ case reflect.Bool, reflect.Int, reflect.Int64, reflect.Uint, reflect.Uint64, reflect.String:
+ return true
+ }
+ return false
+}
+
+func SimpleTypeToParam(f reflect.Value) string {
+ switch f.Kind() {
+ case reflect.Bool:
+ return strconv.FormatBool(f.Bool())
+ case reflect.Int, reflect.Int64:
+ // f.Int() is always an int64
+ return strconv.FormatInt(f.Int(), 10)
+ case reflect.Uint, reflect.Uint64:
+ // f.Uint() is always an uint64
+ return strconv.FormatUint(f.Uint(), 10)
+ case reflect.String:
+ return f.String()
+ }
+ panic("the input parameter is not a simple type")
+}