diff options
Diffstat (limited to 'pkg/bindings/images')
21 files changed, 81 insertions, 930 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 8ea09b881..6e16461e5 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -16,9 +16,9 @@ import ( "strings" "github.com/containers/buildah" - "github.com/containers/podman/v2/pkg/auth" - "github.com/containers/podman/v2/pkg/bindings" - "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/auth" + "github.com/containers/podman/v3/pkg/bindings" + "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/storage/pkg/fileutils" "github.com/docker/go-units" "github.com/hashicorp/go-multierror" @@ -57,6 +57,13 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } params.Set("buildargs", bArgs) } + if excludes := options.Excludes; len(excludes) > 0 { + bArgs, err := jsoniter.MarshalToString(excludes) + if err != nil { + return nil, err + } + params.Set("excludes", bArgs) + } if cpuShares := options.CommonBuildOpts.CPUShares; cpuShares > 0 { params.Set("cpushares", strconv.Itoa(int(cpuShares))) } @@ -94,7 +101,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if len(options.From) > 0 { params.Set("from", options.From) } - + if options.IgnoreUnrecognizedInstructions { + params.Set("ignore", "1") + } params.Set("isolation", strconv.Itoa(int(options.Isolation))) if options.CommonBuildOpts.HTTPProxy { params.Set("httpproxy", "1") @@ -159,6 +168,13 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } params.Set("extrahosts", h) } + if nsoptions := options.NamespaceOptions; len(nsoptions) > 0 { + ns, err := jsoniter.MarshalToString(nsoptions) + if err != nil { + return nil, err + } + params.Set("nsoptions", ns) + } if shmSize := options.CommonBuildOpts.ShmSize; len(shmSize) > 0 { shmBytes, err := units.RAMInBytes(shmSize) if err != nil { diff --git a/pkg/bindings/images/diff.go b/pkg/bindings/images/diff.go index 8802c15e2..79b0df8c9 100644 --- a/pkg/bindings/images/diff.go +++ b/pkg/bindings/images/diff.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/containers/podman/v2/pkg/bindings" + "github.com/containers/podman/v3/pkg/bindings" "github.com/containers/storage/pkg/archive" ) diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 37750bc6c..1be2bdfdd 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -8,11 +8,11 @@ import ( "net/url" "strconv" - "github.com/containers/podman/v2/pkg/api/handlers" - "github.com/containers/podman/v2/pkg/auth" - "github.com/containers/podman/v2/pkg/bindings" - "github.com/containers/podman/v2/pkg/domain/entities" - "github.com/containers/podman/v2/pkg/domain/entities/reports" + "github.com/containers/podman/v3/pkg/api/handlers" + "github.com/containers/podman/v3/pkg/auth" + "github.com/containers/podman/v3/pkg/bindings" + "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/domain/entities/reports" "github.com/pkg/errors" ) diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 5669c704e..f4da2d521 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -11,9 +11,9 @@ import ( "os" "strconv" - "github.com/containers/podman/v2/pkg/auth" - "github.com/containers/podman/v2/pkg/bindings" - "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/auth" + "github.com/containers/podman/v3/pkg/bindings" + "github.com/containers/podman/v3/pkg/domain/entities" "github.com/hashicorp/go-multierror" ) @@ -93,7 +93,6 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, default: return images, errors.New("failed to parse pull results stream, unexpected input") } - } return images, mErr } diff --git a/pkg/bindings/images/rm.go b/pkg/bindings/images/rm.go index e652e66aa..beecce7bf 100644 --- a/pkg/bindings/images/rm.go +++ b/pkg/bindings/images/rm.go @@ -4,10 +4,10 @@ import ( "context" "net/http" - "github.com/containers/podman/v2/pkg/api/handlers" - "github.com/containers/podman/v2/pkg/bindings" - "github.com/containers/podman/v2/pkg/domain/entities" - "github.com/containers/podman/v2/pkg/errorhandling" + "github.com/containers/podman/v3/pkg/api/handlers" + "github.com/containers/podman/v3/pkg/bindings" + "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/errorhandling" ) // Remove removes one or more images from the local storage. Use optional force option to remove an diff --git a/pkg/bindings/images/types_diff_options.go b/pkg/bindings/images/types_diff_options.go index edfc7bfa2..f15a9a696 100644 --- a/pkg/bindings/images/types_diff_options.go +++ b/pkg/bindings/images/types_diff_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,60 +12,10 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *DiffOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *DiffOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } diff --git a/pkg/bindings/images/types_exists_options.go b/pkg/bindings/images/types_exists_options.go index 649be4862..2326c398b 100644 --- a/pkg/bindings/images/types_exists_options.go +++ b/pkg/bindings/images/types_exists_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,60 +12,10 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *ExistsOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *ExistsOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } diff --git a/pkg/bindings/images/types_export_options.go b/pkg/bindings/images/types_export_options.go index ebd053165..0c5a3390c 100644 --- a/pkg/bindings/images/types_export_options.go +++ b/pkg/bindings/images/types_export_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *ExportOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *ExportOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithCompress diff --git a/pkg/bindings/images/types_get_options.go b/pkg/bindings/images/types_get_options.go index 33ebe2611..33da7b0be 100644 --- a/pkg/bindings/images/types_get_options.go +++ b/pkg/bindings/images/types_get_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *GetOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *GetOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithSize diff --git a/pkg/bindings/images/types_history_options.go b/pkg/bindings/images/types_history_options.go index b2c37acea..191375390 100644 --- a/pkg/bindings/images/types_history_options.go +++ b/pkg/bindings/images/types_history_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,60 +12,10 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *HistoryOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *HistoryOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } diff --git a/pkg/bindings/images/types_import_options.go b/pkg/bindings/images/types_import_options.go index e2aed0866..333e841e6 100644 --- a/pkg/bindings/images/types_import_options.go +++ b/pkg/bindings/images/types_import_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *ImportOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *ImportOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithChanges diff --git a/pkg/bindings/images/types_list_options.go b/pkg/bindings/images/types_list_options.go index e194474b9..e86157f59 100644 --- a/pkg/bindings/images/types_list_options.go +++ b/pkg/bindings/images/types_list_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *ListOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *ListOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAll diff --git a/pkg/bindings/images/types_load_options.go b/pkg/bindings/images/types_load_options.go index 7e15d4e03..7b2e504d9 100644 --- a/pkg/bindings/images/types_load_options.go +++ b/pkg/bindings/images/types_load_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *LoadOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *LoadOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithReference diff --git a/pkg/bindings/images/types_prune_options.go b/pkg/bindings/images/types_prune_options.go index f86676d53..6bd0c0f6f 100644 --- a/pkg/bindings/images/types_prune_options.go +++ b/pkg/bindings/images/types_prune_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *PruneOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *PruneOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAll diff --git a/pkg/bindings/images/types_pull_options.go b/pkg/bindings/images/types_pull_options.go index 59e2b6354..0611c4447 100644 --- a/pkg/bindings/images/types_pull_options.go +++ b/pkg/bindings/images/types_pull_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *PullOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAllTags diff --git a/pkg/bindings/images/types_push_options.go b/pkg/bindings/images/types_push_options.go index 85f1ffee5..2593c2fe0 100644 --- a/pkg/bindings/images/types_push_options.go +++ b/pkg/bindings/images/types_push_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *PushOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *PushOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAll diff --git a/pkg/bindings/images/types_remove_options.go b/pkg/bindings/images/types_remove_options.go index d79186565..d591aae88 100644 --- a/pkg/bindings/images/types_remove_options.go +++ b/pkg/bindings/images/types_remove_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *RemoveOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *RemoveOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAll diff --git a/pkg/bindings/images/types_search_options.go b/pkg/bindings/images/types_search_options.go index a55c9ac89..a437a0934 100644 --- a/pkg/bindings/images/types_search_options.go +++ b/pkg/bindings/images/types_search_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *SearchOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithAuthfile diff --git a/pkg/bindings/images/types_tag_options.go b/pkg/bindings/images/types_tag_options.go index b323ea41c..25cb8f68b 100644 --- a/pkg/bindings/images/types_tag_options.go +++ b/pkg/bindings/images/types_tag_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,60 +12,10 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *TagOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *TagOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } diff --git a/pkg/bindings/images/types_tree_options.go b/pkg/bindings/images/types_tree_options.go index 8e1b16c5c..43178113d 100644 --- a/pkg/bindings/images/types_tree_options.go +++ b/pkg/bindings/images/types_tree_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,62 +12,12 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *TreeOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *TreeOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } // WithWhatRequires diff --git a/pkg/bindings/images/types_untag_options.go b/pkg/bindings/images/types_untag_options.go index b28670134..520cf7a49 100644 --- a/pkg/bindings/images/types_untag_options.go +++ b/pkg/bindings/images/types_untag_options.go @@ -2,12 +2,8 @@ package images import ( "net/url" - "reflect" - "strings" - "github.com/containers/podman/v2/pkg/bindings/util" - jsoniter "github.com/json-iterator/go" - "github.com/pkg/errors" + "github.com/containers/podman/v3/pkg/bindings/internal/util" ) /* @@ -16,60 +12,10 @@ This file is generated automatically by go generate. Do not edit. // Changed func (o *UntagOptions) Changed(fieldName string) bool { - r := reflect.ValueOf(o) - value := reflect.Indirect(r).FieldByName(fieldName) - return !value.IsNil() + return util.Changed(o, fieldName) } // ToParams func (o *UntagOptions) 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 - } - fieldName = strings.ToLower(fieldName) - f := s.Field(i) - if reflect.Ptr == f.Kind() { - f = f.Elem() - } - switch { - case util.IsSimpleType(f): - params.Set(fieldName, util.SimpleTypeToParam(f)) - case f.Kind() == reflect.Slice: - for i := 0; i < f.Len(); i++ { - elem := f.Index(i) - if util.IsSimpleType(elem) { - params.Add(fieldName, util.SimpleTypeToParam(elem)) - } else { - return nil, errors.New("slices must contain only simple types") - } - } - case f.Kind() == 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) - } - - } - return params, nil + return util.ToParams(o) } |