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_pull_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_pull_options.go')
-rw-r--r-- | pkg/bindings/images/types_pull_options.go | 280 |
1 files changed, 280 insertions, 0 deletions
diff --git a/pkg/bindings/images/types_pull_options.go b/pkg/bindings/images/types_pull_options.go new file mode 100644 index 000000000..10d0c53e8 --- /dev/null +++ b/pkg/bindings/images/types_pull_options.go @@ -0,0 +1,280 @@ +package images + +import ( + "net/url" + "reflect" + "strconv" + + "github.com/containers/common/pkg/config" + 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.373345229 -0600 CST m=+0.000247562 +*/ + +// Changed +func (o *PullOptions) Changed(fieldName string) bool { + r := reflect.ValueOf(o) + value := reflect.Indirect(r).FieldByName(fieldName) + return !value.IsNil() +} + +// ToParams +func (o *PullOptions) 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 +} + +// WithAllTags +func (o *PullOptions) WithAllTags(value bool) *PullOptions { + v := &value + o.AllTags = v + return o +} + +// GetAllTags +func (o *PullOptions) GetAllTags() bool { + var allTags bool + if o.AllTags == nil { + return allTags + } + return *o.AllTags +} + +// WithAuthfile +func (o *PullOptions) WithAuthfile(value string) *PullOptions { + v := &value + o.Authfile = v + return o +} + +// GetAuthfile +func (o *PullOptions) GetAuthfile() string { + var authfile string + if o.Authfile == nil { + return authfile + } + return *o.Authfile +} + +// WithCertDir +func (o *PullOptions) WithCertDir(value string) *PullOptions { + v := &value + o.CertDir = v + return o +} + +// GetCertDir +func (o *PullOptions) GetCertDir() string { + var certDir string + if o.CertDir == nil { + return certDir + } + return *o.CertDir +} + +// WithUsername +func (o *PullOptions) WithUsername(value string) *PullOptions { + v := &value + o.Username = v + return o +} + +// GetUsername +func (o *PullOptions) GetUsername() string { + var username string + if o.Username == nil { + return username + } + return *o.Username +} + +// WithPassword +func (o *PullOptions) WithPassword(value string) *PullOptions { + v := &value + o.Password = v + return o +} + +// GetPassword +func (o *PullOptions) GetPassword() string { + var password string + if o.Password == nil { + return password + } + return *o.Password +} + +// WithOverrideArch +func (o *PullOptions) WithOverrideArch(value string) *PullOptions { + v := &value + o.OverrideArch = v + return o +} + +// GetOverrideArch +func (o *PullOptions) GetOverrideArch() string { + var overrideArch string + if o.OverrideArch == nil { + return overrideArch + } + return *o.OverrideArch +} + +// WithOverrideOS +func (o *PullOptions) WithOverrideOS(value string) *PullOptions { + v := &value + o.OverrideOS = v + return o +} + +// GetOverrideOS +func (o *PullOptions) GetOverrideOS() string { + var overrideOS string + if o.OverrideOS == nil { + return overrideOS + } + return *o.OverrideOS +} + +// WithOverrideVariant +func (o *PullOptions) WithOverrideVariant(value string) *PullOptions { + v := &value + o.OverrideVariant = v + return o +} + +// GetOverrideVariant +func (o *PullOptions) GetOverrideVariant() string { + var overrideVariant string + if o.OverrideVariant == nil { + return overrideVariant + } + return *o.OverrideVariant +} + +// WithQuiet +func (o *PullOptions) WithQuiet(value bool) *PullOptions { + v := &value + o.Quiet = v + return o +} + +// GetQuiet +func (o *PullOptions) GetQuiet() bool { + var quiet bool + if o.Quiet == nil { + return quiet + } + return *o.Quiet +} + +// WithSignaturePolicy +func (o *PullOptions) WithSignaturePolicy(value string) *PullOptions { + v := &value + o.SignaturePolicy = v + return o +} + +// GetSignaturePolicy +func (o *PullOptions) GetSignaturePolicy() string { + var signaturePolicy string + if o.SignaturePolicy == nil { + return signaturePolicy + } + return *o.SignaturePolicy +} + +// WithSkipTLSVerify +func (o *PullOptions) WithSkipTLSVerify(value bool) *PullOptions { + v := &value + o.SkipTLSVerify = v + return o +} + +// GetSkipTLSVerify +func (o *PullOptions) GetSkipTLSVerify() bool { + var skipTLSVerify bool + if o.SkipTLSVerify == nil { + return skipTLSVerify + } + return *o.SkipTLSVerify +} + +// WithPullPolicy +func (o *PullOptions) WithPullPolicy(value config.PullPolicy) *PullOptions { + v := &value + o.PullPolicy = v + return o +} + +// GetPullPolicy +func (o *PullOptions) GetPullPolicy() config.PullPolicy { + var pullPolicy config.PullPolicy + if o.PullPolicy == nil { + return pullPolicy + } + return *o.PullPolicy +} |