vendor: update copystructure/reflectwalk

This adds fixes that are needed for ResourceConfig copying, namely
related to copying interfaces, avoiding unexported fields.
This commit is contained in:
Mitchell Hashimoto 2016-09-27 16:08:54 -07:00
parent 376f0827a3
commit 99e706b502
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 31 additions and 7 deletions

View File

@ -295,12 +295,24 @@ func (w *walker) StructField(f reflect.StructField, v reflect.Value) error {
return nil
}
// If PkgPath is non-empty, this is a private (unexported) field.
// We do not set this unexported since the Go runtime doesn't allow us.
if f.PkgPath != "" {
w.ignore()
return nil
}
// Push the field onto the stack, we'll handle it when we exit
// the struct field in Exit...
w.valPush(reflect.ValueOf(f))
return nil
}
// ignore causes the walker to ignore any more values until we exit this on
func (w *walker) ignore() {
w.ignoreDepth = w.depth
}
func (w *walker) ignoring() bool {
return w.ignoreDepth > 0 && w.depth >= w.ignoreDepth
}

View File

@ -4,9 +4,7 @@
// those elements.
package reflectwalk
import (
"reflect"
)
import "reflect"
// PrimitiveWalker implementations are able to handle primitive values
// within complex structures. Primitive values are numbers, strings,
@ -145,6 +143,12 @@ func walkMap(v reflect.Value, w interface{}) error {
for _, k := range v.MapKeys() {
kv := v.MapIndex(k)
// if the map value type is an interface, we need to extract the Elem
// for the next call to walk
if kv.Kind() == reflect.Interface {
kv = kv.Elem()
}
if mw, ok := w.(MapWalker); ok {
if err := mw.MapElem(v, k, kv); err != nil {
return err
@ -204,6 +208,12 @@ func walkSlice(v reflect.Value, w interface{}) (err error) {
for i := 0; i < v.Len(); i++ {
elem := v.Index(i)
// if the value type is an interface, we need to extract the Elem
// for the next call to walk
if elem.Kind() == reflect.Interface {
elem = elem.Elem()
}
if sw, ok := w.(SliceWalker); ok {
if err := sw.SliceElem(i, elem); err != nil {
return err

10
vendor/vendor.json vendored
View File

@ -1472,10 +1472,10 @@
"revision": "8631ce90f28644f54aeedcb3e389a85174e067d1"
},
{
"checksumSHA1": "Vfkp+PcZ1wZ4+D6AsHTpKkdsQG0=",
"checksumSHA1": "EDAtec3XSbTjw6gWG+NNScows9M=",
"path": "github.com/mitchellh/copystructure",
"revision": "501dcbdc7c358c4d0bfa066018834bedca79fde3",
"revisionTime": "2016-09-16T19:51:24Z"
"revision": "8f3c396a26dadccbd29ee24c76c89166249cc16f",
"revisionTime": "2016-09-27T21:34:29Z"
},
{
"path": "github.com/mitchellh/go-homedir",
@ -1507,8 +1507,10 @@
"revision": "6e6954073784f7ee67b28f2d22749d6479151ed7"
},
{
"checksumSHA1": "Qfbnn/PnYNR2ZHraUeHTxT4H7lM=",
"path": "github.com/mitchellh/reflectwalk",
"revision": "eecf4c70c626c7cfbb95c90195bc34d386c74ac6"
"revision": "2d53f44828cae4c770d745a3560e37d3356774a6",
"revisionTime": "2016-09-27T21:55:38Z"
},
{
"checksumSHA1": "/iig5lYSPCL3C8J7e4nTAevYNDE=",