mirror of https://github.com/containers/podman.git
Merge pull request #9203 from matejvasek/improve_param_serder_generator
[NO TESTS NEEDED] Improve binding generator
This commit is contained in:
commit
881f3d788d
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *AttachOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *AttachOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *CheckpointOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CheckpointOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *CommitOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CommitOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *DiffOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *DiffOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExecInspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExecInspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExecStartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExecStartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -45,33 +45,19 @@ func (o *ExecStartAndAttachOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -85,6 +71,7 @@ func (o *ExecStartAndAttachOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExportOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExportOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *HealthCheckOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *HealthCheckOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InitOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InitOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *KillOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *KillOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *LogOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *LogOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *MountOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *MountOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *MountedContainerPathsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *MountedContainerPathsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PauseOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PauseOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RenameOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RenameOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ResizeExecTTYOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ResizeExecTTYOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ResizeTTYOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ResizeTTYOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RestartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RestartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RestoreOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RestoreOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ShouldRestartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ShouldRestartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StatsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StatsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StopOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StopOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *TopOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *TopOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *UnmountOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *UnmountOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package containers
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/podman/v2/libpod/define"
|
"github.com/containers/podman/v2/libpod/define"
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -44,33 +44,19 @@ func (o *WaitOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -84,6 +70,7 @@ func (o *WaitOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package generate
|
package generate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *KubeOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *KubeOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package generate
|
package generate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *SystemdOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *SystemdOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,33 +54,19 @@ func (o *{{.StructName}}) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -94,6 +80,7 @@ func (o *{{.StructName}}) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
@ -144,7 +131,7 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
// always add reflect
|
// always add reflect
|
||||||
imports := []string{"\"reflect\""}
|
imports := []string{"\"reflect\"", "\"github.com/containers/podman/v2/pkg/bindings/util\""}
|
||||||
for _, imp := range f.Imports {
|
for _, imp := range f.Imports {
|
||||||
imports = append(imports, imp.Path.Value)
|
imports = append(imports, imp.Path.Value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *DiffOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *DiffOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExportOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExportOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *GetOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *GetOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *HistoryOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *HistoryOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ImportOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ImportOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *LoadOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *LoadOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PullOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PullOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PushOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PushOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *SearchOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *SearchOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *TagOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *TagOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *TreeOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *TreeOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package images
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *UntagOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *UntagOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package manifests
|
package manifests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *AddOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *AddOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package manifests
|
package manifests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package manifests
|
package manifests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package manifests
|
package manifests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package manifests
|
package manifests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ConnectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ConnectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -44,33 +44,19 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -84,6 +70,7 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *DisconnectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *DisconnectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package network
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package play
|
package play
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,33 +43,19 @@ func (o *KubeOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *KubeOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *KillOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *KillOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PauseOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PauseOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RestartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RestartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StartOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StartOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StatsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StatsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *StopOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *StopOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *TopOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *TopOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package pods
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package system
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *DiskOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *DiskOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package system
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *EventsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *EventsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package system
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InfoOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InfoOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package system
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package system
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *VersionOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *VersionOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -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")
|
||||||
|
}
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *CreateOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ExistsOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *InspectOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *ListOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *PruneOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package volumes
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/podman/v2/pkg/bindings/util"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -43,33 +43,19 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
if reflect.Ptr == f.Kind() {
|
if reflect.Ptr == f.Kind() {
|
||||||
f = f.Elem()
|
f = f.Elem()
|
||||||
}
|
}
|
||||||
switch f.Kind() {
|
switch {
|
||||||
case reflect.Bool:
|
case util.IsSimpleType(f):
|
||||||
params.Set(fieldName, strconv.FormatBool(f.Bool()))
|
params.Set(fieldName, util.SimpleTypeToParam(f))
|
||||||
case reflect.String:
|
case f.Kind() == reflect.Slice:
|
||||||
params.Set(fieldName, f.String())
|
for i := 0; i < f.Len(); i++ {
|
||||||
case reflect.Int, reflect.Int64:
|
elem := f.Index(i)
|
||||||
// f.Int() is always an int64
|
if util.IsSimpleType(elem) {
|
||||||
params.Set(fieldName, strconv.FormatInt(f.Int(), 10))
|
params.Add(fieldName, util.SimpleTypeToParam(elem))
|
||||||
case reflect.Uint, reflect.Uint64:
|
} else {
|
||||||
// f.Uint() is always an uint64
|
return nil, errors.New("slices must contain only simple types")
|
||||||
params.Set(fieldName, strconv.FormatUint(f.Uint(), 10))
|
|
||||||
case reflect.Slice:
|
|
||||||
typ := reflect.TypeOf(f.Interface()).Elem()
|
|
||||||
switch typ.Kind() {
|
|
||||||
case reflect.String:
|
|
||||||
sl := f.Slice(0, f.Len())
|
|
||||||
s, ok := sl.Interface().([]string)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("failed to convert to string slice")
|
|
||||||
}
|
}
|
||||||
for _, val := range s {
|
|
||||||
params.Add(fieldName, val)
|
|
||||||
}
|
}
|
||||||
default:
|
case f.Kind() == reflect.Map:
|
||||||
return nil, errors.Errorf("unknown slice type %s", f.Kind().String())
|
|
||||||
}
|
|
||||||
case reflect.Map:
|
|
||||||
lowerCaseKeys := make(map[string][]string)
|
lowerCaseKeys := make(map[string][]string)
|
||||||
iter := f.MapRange()
|
iter := f.MapRange()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
|
@ -83,6 +69,7 @@ func (o *RemoveOptions) ToParams() (url.Values, error) {
|
||||||
|
|
||||||
params.Set(fieldName, s)
|
params.Set(fieldName, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue