Merge pull request #23006 from containers/renovate/github.com-gorilla-schema-1.x

Update module github.com/gorilla/schema to v1.4.0
This commit is contained in:
openshift-merge-bot[bot] 2024-06-17 19:38:02 +00:00 committed by GitHub
commit afe55cded0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 13 deletions

2
go.mod
View File

@ -40,7 +40,7 @@ require (
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2 github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
github.com/gorilla/schema v1.3.0 github.com/gorilla/schema v1.4.0
github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-multierror v1.1.1
github.com/hugelgupf/p9 v0.3.1-0.20230822151754-54f5c5530921 github.com/hugelgupf/p9 v0.3.1-0.20230822151754-54f5c5530921
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12

4
go.sum
View File

@ -277,8 +277,8 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA= github.com/gorilla/schema v1.4.0 h1:l2N+lRTJtev9SUhBtj6NmSxd/6+8LhvN0kV+H2Y8R9k=
github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/schema v1.4.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=

View File

@ -104,6 +104,15 @@ func (d *Decoder) setDefaults(t reflect.Type, v reflect.Value) MultiError {
errs := MultiError{} errs := MultiError{}
if v.Type().Kind() == reflect.Struct {
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
if field.Type().Kind() == reflect.Ptr && field.IsNil() && v.Type().Field(i).Anonymous {
field.Set(reflect.New(field.Type().Elem()))
}
}
}
for _, f := range struc.fields { for _, f := range struc.fields {
vCurrent := v.FieldByName(f.name) vCurrent := v.FieldByName(f.name)
@ -130,9 +139,12 @@ func (d *Decoder) setDefaults(t reflect.Type, v reflect.Value) MultiError {
defaultSlice := reflect.MakeSlice(f.typ, 0, cap(vals)) defaultSlice := reflect.MakeSlice(f.typ, 0, cap(vals))
for _, val := range vals { for _, val := range vals {
// this check is to handle if the wrong value is provided // this check is to handle if the wrong value is provided
if convertedVal := builtinConverters[f.typ.Elem().Kind()](val); convertedVal.IsValid() { convertedVal := builtinConverters[f.typ.Elem().Kind()](val)
defaultSlice = reflect.Append(defaultSlice, convertedVal) if !convertedVal.IsValid() {
errs.merge(MultiError{"default-" + f.name: fmt.Errorf("failed setting default: %s is not compatible with field %s type", val, f.name)})
break
} }
defaultSlice = reflect.Append(defaultSlice, convertedVal)
} }
vCurrent.Set(defaultSlice) vCurrent.Set(defaultSlice)
} else if f.typ.Kind() == reflect.Ptr { } else if f.typ.Kind() == reflect.Ptr {

2
vendor/modules.txt vendored
View File

@ -684,7 +684,7 @@ github.com/gorilla/handlers
# github.com/gorilla/mux v1.8.1 # github.com/gorilla/mux v1.8.1
## explicit; go 1.20 ## explicit; go 1.20
github.com/gorilla/mux github.com/gorilla/mux
# github.com/gorilla/schema v1.3.0 # github.com/gorilla/schema v1.4.0
## explicit; go 1.20 ## explicit; go 1.20
github.com/gorilla/schema github.com/gorilla/schema
# github.com/hashicorp/errwrap v1.1.0 # github.com/hashicorp/errwrap v1.1.0