diff --git a/config/interpolate_walk_test.go b/config/interpolate_walk_test.go index 70067a99c..35b8f1f57 100644 --- a/config/interpolate_walk_test.go +++ b/config/interpolate_walk_test.go @@ -179,13 +179,15 @@ func TestInterpolationWalker_replace(t *testing.T) { return tc.Value, nil } - w := &interpolationWalker{F: fn, Replace: true} - if err := reflectwalk.Walk(tc.Input, w); err != nil { - t.Fatalf("err: %s", err) - } + 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) + } - if !reflect.DeepEqual(tc.Input, tc.Output) { - t.Fatalf("%d: bad:\n\nexpected:%#v\ngot:%#v", i, tc.Output, tc.Input) - } + if !reflect.DeepEqual(tc.Input, tc.Output) { + t.Fatalf("%d: bad:\n\nexpected:%#v\ngot:%#v", i, tc.Output, tc.Input) + } + }) } } diff --git a/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go b/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go index fafd443a4..6066014c4 100644 --- a/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go +++ b/vendor/github.com/mitchellh/reflectwalk/reflectwalk.go @@ -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 diff --git a/vendor/vendor.json b/vendor/vendor.json index 8bd359be9..4b9d1902e 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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=",