Update reflectwalk to fix failing tests
As part of working on ResourceConfig.DeepCopy, Equal I updated reflectwalk (to fix some issues in the new functions) but this introduced more issues in other parts of Terraform. This update fixes those.
This commit is contained in:
parent
f897fa4701
commit
37c880c377
|
@ -179,6 +179,7 @@ func TestInterpolationWalker_replace(t *testing.T) {
|
|||
return tc.Value, nil
|
||||
}
|
||||
|
||||
t.Run(fmt.Sprintf("walk-%d", i), func(t *testing.T) {
|
||||
w := &interpolationWalker{F: fn, Replace: true}
|
||||
if err := reflectwalk.Walk(tc.Input, w); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -187,5 +188,6 @@ func TestInterpolationWalker_replace(t *testing.T) {
|
|||
if !reflect.DeepEqual(tc.Input, tc.Output) {
|
||||
t.Fatalf("%d: bad:\n\nexpected:%#v\ngot:%#v", i, tc.Output, tc.Input)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,14 @@ func Walk(data, walker interface{}) (err error) {
|
|||
}
|
||||
|
||||
func walk(v reflect.Value, w interface{}) (err error) {
|
||||
// We preserve the original value here because if it is an interface
|
||||
// type, we want to pass that directly into the walkPrimitive, so that
|
||||
// we can set it.
|
||||
originalV := v
|
||||
if v.Kind() == reflect.Interface {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
// Determine if we're receiving a pointer and if so notify the walker.
|
||||
pointer := false
|
||||
if v.Kind() == reflect.Ptr {
|
||||
|
@ -96,14 +104,6 @@ func walk(v reflect.Value, w interface{}) (err error) {
|
|||
}()
|
||||
}
|
||||
|
||||
// We preserve the original value here because if it is an interface
|
||||
// type, we want to pass that directly into the walkPrimitive, so that
|
||||
// we can set it.
|
||||
originalV := v
|
||||
if v.Kind() == reflect.Interface {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
k := v.Kind()
|
||||
if k >= reflect.Int && k <= reflect.Complex128 {
|
||||
k = reflect.Int
|
||||
|
@ -143,12 +143,6 @@ 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
|
||||
|
@ -208,12 +202,6 @@ 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
|
||||
|
|
|
@ -1507,10 +1507,10 @@
|
|||
"revision": "6e6954073784f7ee67b28f2d22749d6479151ed7"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Qfbnn/PnYNR2ZHraUeHTxT4H7lM=",
|
||||
"checksumSHA1": "5fFCVadmQVH6jqnB6Zd739s28QM=",
|
||||
"path": "github.com/mitchellh/reflectwalk",
|
||||
"revision": "2d53f44828cae4c770d745a3560e37d3356774a6",
|
||||
"revisionTime": "2016-09-27T21:55:38Z"
|
||||
"revision": "84fc159ad78a797bb094a1e0c364392d837e1cd8",
|
||||
"revisionTime": "2016-09-28T02:14:22Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "/iig5lYSPCL3C8J7e4nTAevYNDE=",
|
||||
|
|
Loading…
Reference in New Issue