diff options
author | baude <bbaude@redhat.com> | 2020-12-14 08:52:00 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2020-12-15 16:04:59 -0600 |
commit | 8d4e19634cf73f257ca7f5d2c9506183f6a5b183 (patch) | |
tree | b2687888a89a443a4c85b191d42cd4d1a8049c8c /pkg/bindings/images/types_search_options.go | |
parent | 0fd31e29948631c264df21a128b3de2700f7f007 (diff) | |
download | podman-8d4e19634cf73f257ca7f5d2c9506183f6a5b183.tar.gz podman-8d4e19634cf73f257ca7f5d2c9506183f6a5b183.tar.bz2 podman-8d4e19634cf73f257ca7f5d2c9506183f6a5b183.zip |
Podman image bindings for 3.0
Begin the migration of the image bindings for podman 3.0. this includes
the use of options for each binding. build was intentionally not
converted as I believe it needs more discussion before migration.
specifically, the build options themselves.
also noteworthly is that the remove image and remove images bindings
were merged into one. the remove images (or batch remove) has one
downside in that the errors return no longer adhere to http return
codes. this should be discussed and reimplemented in subsequent code.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/images/types_search_options.go')
-rw-r--r-- | pkg/bindings/images/types_search_options.go | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/pkg/bindings/images/types_search_options.go b/pkg/bindings/images/types_search_options.go new file mode 100644 index 000000000..b0b413a6c --- /dev/null +++ b/pkg/bindings/images/types_search_options.go @@ -0,0 +1,183 @@ +package images + +import ( + "net/url" + "reflect" + "strconv" + + jsoniter "github.com/json-iterator/go" + "github.com/pkg/errors" +) + +/* +This file is generated automatically by go generate. Do not edit. + +Created 2020-12-15 15:22:48.229349981 -0600 CST m=+0.000244343 +*/ + +// Changed +func (o *SearchOptions) Changed(fieldName string) bool { + r := reflect.ValueOf(o) + value := reflect.Indirect(r).FieldByName(fieldName) + return !value.IsNil() +} + +// ToParams +func (o *SearchOptions) ToParams() (url.Values, error) { + params := url.Values{} + if o == nil { + return params, nil + } + json := jsoniter.ConfigCompatibleWithStandardLibrary + s := reflect.ValueOf(o) + if reflect.Ptr == s.Kind() { + s = s.Elem() + } + sType := s.Type() + for i := 0; i < s.NumField(); i++ { + fieldName := sType.Field(i).Name + if !o.Changed(fieldName) { + continue + } + f := s.Field(i) + if reflect.Ptr == f.Kind() { + f = f.Elem() + } + switch f.Kind() { + case reflect.Bool: + params.Set(fieldName, strconv.FormatBool(f.Bool())) + case reflect.String: + params.Set(fieldName, f.String()) + case reflect.Int, reflect.Int64: + // f.Int() is always an int64 + params.Set(fieldName, strconv.FormatInt(f.Int(), 10)) + case reflect.Slice: + typ := reflect.TypeOf(f.Interface()).Elem() + slice := reflect.MakeSlice(reflect.SliceOf(typ), f.Len(), f.Cap()) + switch typ.Kind() { + case reflect.String: + s, ok := slice.Interface().([]string) + if !ok { + return nil, errors.New("failed to convert to string slice") + } + for _, val := range s { + params.Add(fieldName, val) + } + default: + return nil, errors.Errorf("unknown slice type %s", f.Kind().String()) + } + case reflect.Map: + lowerCaseKeys := make(map[string][]string) + iter := f.MapRange() + for iter.Next() { + lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) + + } + s, err := json.MarshalToString(lowerCaseKeys) + if err != nil { + return nil, err + } + + params.Set(fieldName, s) + default: + return nil, errors.Errorf("unknown type %s", f.Kind().String()) + } + } + return params, nil +} + +// WithAuthfile +func (o *SearchOptions) WithAuthfile(value string) *SearchOptions { + v := &value + o.Authfile = v + return o +} + +// GetAuthfile +func (o *SearchOptions) GetAuthfile() string { + var authfile string + if o.Authfile == nil { + return authfile + } + return *o.Authfile +} + +// WithFilters +func (o *SearchOptions) WithFilters(value map[string][]string) *SearchOptions { + v := value + o.Filters = v + return o +} + +// GetFilters +func (o *SearchOptions) GetFilters() map[string][]string { + var filters map[string][]string + if o.Filters == nil { + return filters + } + return o.Filters +} + +// WithLimit +func (o *SearchOptions) WithLimit(value int) *SearchOptions { + v := &value + o.Limit = v + return o +} + +// GetLimit +func (o *SearchOptions) GetLimit() int { + var limit int + if o.Limit == nil { + return limit + } + return *o.Limit +} + +// WithNoTrunc +func (o *SearchOptions) WithNoTrunc(value bool) *SearchOptions { + v := &value + o.NoTrunc = v + return o +} + +// GetNoTrunc +func (o *SearchOptions) GetNoTrunc() bool { + var noTrunc bool + if o.NoTrunc == nil { + return noTrunc + } + return *o.NoTrunc +} + +// WithSkipTLSVerify +func (o *SearchOptions) WithSkipTLSVerify(value bool) *SearchOptions { + v := &value + o.SkipTLSVerify = v + return o +} + +// GetSkipTLSVerify +func (o *SearchOptions) GetSkipTLSVerify() bool { + var skipTLSVerify bool + if o.SkipTLSVerify == nil { + return skipTLSVerify + } + return *o.SkipTLSVerify +} + +// WithListTags +func (o *SearchOptions) WithListTags(value bool) *SearchOptions { + v := &value + o.ListTags = v + return o +} + +// GetListTags +func (o *SearchOptions) GetListTags() bool { + var listTags bool + if o.ListTags == nil { + return listTags + } + return *o.ListTags +} |