Merge pull request #5640 from hashicorp/b-fix-omitempty
Update hashicorp/go-msgpack/codec
This commit is contained in:
commit
5c498112ff
2
vendor/github.com/hashicorp/go-msgpack/codec/decode.go
generated
vendored
2
vendor/github.com/hashicorp/go-msgpack/codec/decode.go
generated
vendored
|
@ -527,7 +527,7 @@ func (f *decFnInfo) kMap(rv reflect.Value) {
|
|||
}
|
||||
}
|
||||
rvv := rv.MapIndex(rvk)
|
||||
if !rvv.IsValid() {
|
||||
if !rvv.IsValid() || !rvv.CanSet() {
|
||||
rvv = reflect.New(vtype).Elem()
|
||||
}
|
||||
|
||||
|
|
7
vendor/github.com/hashicorp/go-msgpack/codec/helper.go
generated
vendored
7
vendor/github.com/hashicorp/go-msgpack/codec/helper.go
generated
vendored
|
@ -45,6 +45,13 @@ const (
|
|||
// for debugging, set this to false, to catch panic traces.
|
||||
// Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic.
|
||||
recoverPanicToErr = true
|
||||
|
||||
// if checkStructForEmptyValue, check structs fields to see if an empty value.
|
||||
// This could be an expensive call, so possibly disable it.
|
||||
checkStructForEmptyValue = false
|
||||
|
||||
// if derefForIsEmptyValue, deref pointers and interfaces when checking isEmptyValue
|
||||
derefForIsEmptyValue = false
|
||||
)
|
||||
|
||||
type charEncoding uint8
|
||||
|
|
13
vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go
generated
vendored
13
vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go
generated
vendored
|
@ -33,8 +33,10 @@ func panicValToErr(panicVal interface{}, err *error) {
|
|||
return
|
||||
}
|
||||
|
||||
func isEmptyValueDeref(v reflect.Value, deref bool) bool {
|
||||
func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Invalid:
|
||||
return true
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Bool:
|
||||
|
@ -50,18 +52,21 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool {
|
|||
if v.IsNil() {
|
||||
return true
|
||||
}
|
||||
return isEmptyValueDeref(v.Elem(), deref)
|
||||
return hIsEmptyValue(v.Elem(), deref, checkStruct)
|
||||
} else {
|
||||
return v.IsNil()
|
||||
}
|
||||
case reflect.Struct:
|
||||
if !checkStruct {
|
||||
return false
|
||||
}
|
||||
// return true if all fields are empty. else return false.
|
||||
|
||||
// we cannot use equality check, because some fields may be maps/slices/etc
|
||||
// and consequently the structs are not comparable.
|
||||
// return v.Interface() == reflect.Zero(v.Type()).Interface()
|
||||
for i, n := 0, v.NumField(); i < n; i++ {
|
||||
if !isEmptyValueDeref(v.Field(i), deref) {
|
||||
if !hIsEmptyValue(v.Field(i), deref, checkStruct) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +76,7 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool {
|
|||
}
|
||||
|
||||
func isEmptyValue(v reflect.Value) bool {
|
||||
return isEmptyValueDeref(v, true)
|
||||
return hIsEmptyValue(v, derefForIsEmptyValue, checkStructForEmptyValue)
|
||||
}
|
||||
|
||||
func debugf(format string, args ...interface{}) {
|
||||
|
|
2
vendor/vendor.json
vendored
2
vendor/vendor.json
vendored
|
@ -194,7 +194,7 @@
|
|||
{"path":"github.com/hashicorp/go-hclog","checksumSHA1":"dOP7kCX3dACHc9mU79826N411QA=","revision":"ff2cf002a8dd750586d91dddd4470c341f981fe1","revisionTime":"2018-07-09T16:53:50Z"},
|
||||
{"path":"github.com/hashicorp/go-immutable-radix","checksumSHA1":"Cas2nprG6pWzf05A2F/OlnjUu2Y=","revision":"8aac2701530899b64bdea735a1de8da899815220","revisionTime":"2017-07-25T22:12:15Z"},
|
||||
{"path":"github.com/hashicorp/go-memdb","checksumSHA1":"FMAvwDar2bQyYAW4XMFhAt0J5xA=","revision":"20ff6434c1cc49b80963d45bf5c6aa89c78d8d57","revisionTime":"2017-08-31T20:15:40Z"},
|
||||
{"path":"github.com/hashicorp/go-msgpack/codec","checksumSHA1":"TNlVzNR1OaajcNi3CbQ3bGbaLGU=","revision":"fa3f63826f7c23912c15263591e65d54d080b458"},
|
||||
{"path":"github.com/hashicorp/go-msgpack/codec","checksumSHA1":"bhZWU3QDhQQ96g9tOLd2muPrUAs=","revision":"ad60660ecf9c5a1eae0ca32182ed72bab5807961","revisionTime":"2019-05-02T14:51:04Z"},
|
||||
{"path":"github.com/hashicorp/go-multierror","checksumSHA1":"lrSl49G23l6NhfilxPM0XFs5rZo=","revision":"d30f09973e19c1dfcd120b2d9c4f168e68d6b5d5"},
|
||||
{"path":"github.com/hashicorp/go-plugin","checksumSHA1":"IFwYSAmxxM+fV0w9LwdWKqFOCgg=","revision":"f444068e8f5a19853177f7aa0aea7e7d95b5b528","revisionTime":"2018-12-12T15:08:38Z"},
|
||||
{"path":"github.com/hashicorp/go-plugin/internal/proto","checksumSHA1":"Ikbb1FngsPR79bHhr2UmKk4CblI=","revision":"f444068e8f5a19853177f7aa0aea7e7d95b5b528","revisionTime":"2018-12-12T15:08:38Z"},
|
||||
|
|
Loading…
Reference in a new issue