mirror of
https://github.com/containers/podman.git
synced 2025-05-28 21:46:51 +08:00
update c/{buildah,common,image,storage} to latest main
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
57
vendor/github.com/go-openapi/validate/slice_validator.go
generated
vendored
57
vendor/github.com/go-openapi/validate/slice_validator.go
generated
vendored
@ -32,7 +32,36 @@ type schemaSliceValidator struct {
|
||||
Items *spec.SchemaOrArray
|
||||
Root interface{}
|
||||
KnownFormats strfmt.Registry
|
||||
Options SchemaValidatorOptions
|
||||
Options *SchemaValidatorOptions
|
||||
}
|
||||
|
||||
func newSliceValidator(path, in string,
|
||||
maxItems, minItems *int64, uniqueItems bool,
|
||||
additionalItems *spec.SchemaOrBool, items *spec.SchemaOrArray,
|
||||
root interface{}, formats strfmt.Registry, opts *SchemaValidatorOptions) *schemaSliceValidator {
|
||||
if opts == nil {
|
||||
opts = new(SchemaValidatorOptions)
|
||||
}
|
||||
|
||||
var v *schemaSliceValidator
|
||||
if opts.recycleValidators {
|
||||
v = pools.poolOfSliceValidators.BorrowValidator()
|
||||
} else {
|
||||
v = new(schemaSliceValidator)
|
||||
}
|
||||
|
||||
v.Path = path
|
||||
v.In = in
|
||||
v.MaxItems = maxItems
|
||||
v.MinItems = minItems
|
||||
v.UniqueItems = uniqueItems
|
||||
v.AdditionalItems = additionalItems
|
||||
v.Items = items
|
||||
v.Root = root
|
||||
v.KnownFormats = formats
|
||||
v.Options = opts
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *schemaSliceValidator) SetPath(path string) {
|
||||
@ -46,7 +75,18 @@ func (s *schemaSliceValidator) Applies(source interface{}, kind reflect.Kind) bo
|
||||
}
|
||||
|
||||
func (s *schemaSliceValidator) Validate(data interface{}) *Result {
|
||||
result := new(Result)
|
||||
if s.Options.recycleValidators {
|
||||
defer func() {
|
||||
s.redeem()
|
||||
}()
|
||||
}
|
||||
|
||||
var result *Result
|
||||
if s.Options.recycleResult {
|
||||
result = pools.poolOfResults.BorrowResult()
|
||||
} else {
|
||||
result = new(Result)
|
||||
}
|
||||
if data == nil {
|
||||
return result
|
||||
}
|
||||
@ -54,8 +94,8 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
|
||||
size := val.Len()
|
||||
|
||||
if s.Items != nil && s.Items.Schema != nil {
|
||||
validator := NewSchemaValidator(s.Items.Schema, s.Root, s.Path, s.KnownFormats, s.Options.Options()...)
|
||||
for i := 0; i < size; i++ {
|
||||
validator := newSchemaValidator(s.Items.Schema, s.Root, s.Path, s.KnownFormats, s.Options)
|
||||
validator.SetPath(fmt.Sprintf("%s.%d", s.Path, i))
|
||||
value := val.Index(i)
|
||||
result.mergeForSlice(val, i, validator.Validate(value.Interface()))
|
||||
@ -66,10 +106,11 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
|
||||
if s.Items != nil && len(s.Items.Schemas) > 0 {
|
||||
itemsSize = len(s.Items.Schemas)
|
||||
for i := 0; i < itemsSize; i++ {
|
||||
validator := NewSchemaValidator(&s.Items.Schemas[i], s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options.Options()...)
|
||||
if val.Len() <= i {
|
||||
if size <= i {
|
||||
break
|
||||
}
|
||||
|
||||
validator := newSchemaValidator(&s.Items.Schemas[i], s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options)
|
||||
result.mergeForSlice(val, i, validator.Validate(val.Index(i).Interface()))
|
||||
}
|
||||
}
|
||||
@ -79,7 +120,7 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
|
||||
}
|
||||
if s.AdditionalItems.Schema != nil {
|
||||
for i := itemsSize; i < size-itemsSize+1; i++ {
|
||||
validator := NewSchemaValidator(s.AdditionalItems.Schema, s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options.Options()...)
|
||||
validator := newSchemaValidator(s.AdditionalItems.Schema, s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options)
|
||||
result.mergeForSlice(val, i, validator.Validate(val.Index(i).Interface()))
|
||||
}
|
||||
}
|
||||
@ -103,3 +144,7 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
|
||||
result.Inc()
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *schemaSliceValidator) redeem() {
|
||||
pools.poolOfSliceValidators.RedeemValidator(s)
|
||||
}
|
||||
|
Reference in New Issue
Block a user