diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-28 08:27:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-28 08:27:00 -0400 |
commit | ad80e9a10a06a5d3b5a8ff6b286232d4c93ee2ea (patch) | |
tree | 1358b41af41fab4f7534297e33b97a2fc9ef8860 /vendor/github.com/gorilla/schema/decoder.go | |
parent | 74bdf52c401dd1c9cd3c636d4fa8ea94e7c88ef3 (diff) | |
parent | f5d151a2341245bd22f6a64c744eadd61e01539d (diff) | |
download | podman-ad80e9a10a06a5d3b5a8ff6b286232d4c93ee2ea.tar.gz podman-ad80e9a10a06a5d3b5a8ff6b286232d4c93ee2ea.tar.bz2 podman-ad80e9a10a06a5d3b5a8ff6b286232d4c93ee2ea.zip |
Merge pull request #7421 from containers/dependabot/go_modules/github.com/gorilla/schema-1.2.0
Bump github.com/gorilla/schema from 1.1.0 to 1.2.0
Diffstat (limited to 'vendor/github.com/gorilla/schema/decoder.go')
-rw-r--r-- | vendor/github.com/gorilla/schema/decoder.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/vendor/github.com/gorilla/schema/decoder.go b/vendor/github.com/gorilla/schema/decoder.go index 5afbd921f..025e438b5 100644 --- a/vendor/github.com/gorilla/schema/decoder.go +++ b/vendor/github.com/gorilla/schema/decoder.go @@ -152,9 +152,15 @@ type fieldWithPrefix struct { func isEmptyFields(fields []fieldWithPrefix, src map[string][]string) bool { for _, f := range fields { for _, path := range f.paths(f.prefix) { - if !isEmpty(f.typ, src[path]) { + v, ok := src[path] + if ok && !isEmpty(f.typ, v) { return false } + for key := range src { + if !isEmpty(f.typ, src[key]) && strings.HasPrefix(key, path) { + return false + } + } } } return true @@ -182,6 +188,17 @@ func (d *Decoder) decode(v reflect.Value, path string, parts []pathPart, values } v = v.Elem() } + + // alloc embedded structs + 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 == true { + field.Set(reflect.New(field.Type().Elem())) + } + } + } + v = v.FieldByName(name) } // Don't even bother for unexported fields. |