diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/shadow')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/shadow/closer.go | 21 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/shadow/value.go | 8 |
2 files changed, 20 insertions, 9 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/shadow/closer.go b/vendor/github.com/hashicorp/terraform/helper/shadow/closer.go index 7edd5e7..edc1e2a 100644 --- a/vendor/github.com/hashicorp/terraform/helper/shadow/closer.go +++ b/vendor/github.com/hashicorp/terraform/helper/shadow/closer.go | |||
@@ -39,6 +39,8 @@ func (w *closeWalker) Struct(reflect.Value) error { | |||
39 | return nil | 39 | return nil |
40 | } | 40 | } |
41 | 41 | ||
42 | var closerType = reflect.TypeOf((*io.Closer)(nil)).Elem() | ||
43 | |||
42 | func (w *closeWalker) StructField(f reflect.StructField, v reflect.Value) error { | 44 | func (w *closeWalker) StructField(f reflect.StructField, v reflect.Value) error { |
43 | // Not sure why this would be but lets avoid some panics | 45 | // Not sure why this would be but lets avoid some panics |
44 | if !v.IsValid() { | 46 | if !v.IsValid() { |
@@ -56,17 +58,18 @@ func (w *closeWalker) StructField(f reflect.StructField, v reflect.Value) error | |||
56 | return nil | 58 | return nil |
57 | } | 59 | } |
58 | 60 | ||
59 | // We're looking for an io.Closer | 61 | var closer io.Closer |
60 | raw := v.Interface() | 62 | if v.Type().Implements(closerType) { |
61 | if raw == nil { | 63 | closer = v.Interface().(io.Closer) |
62 | return nil | 64 | } else if v.CanAddr() { |
65 | // The Close method may require a pointer receiver, but we only have a value. | ||
66 | v := v.Addr() | ||
67 | if v.Type().Implements(closerType) { | ||
68 | closer = v.Interface().(io.Closer) | ||
69 | } | ||
63 | } | 70 | } |
64 | 71 | ||
65 | closer, ok := raw.(io.Closer) | 72 | if closer == nil { |
66 | if !ok && v.CanAddr() { | ||
67 | closer, ok = v.Addr().Interface().(io.Closer) | ||
68 | } | ||
69 | if !ok { | ||
70 | return reflectwalk.SkipEntry | 73 | return reflectwalk.SkipEntry |
71 | } | 74 | } |
72 | 75 | ||
diff --git a/vendor/github.com/hashicorp/terraform/helper/shadow/value.go b/vendor/github.com/hashicorp/terraform/helper/shadow/value.go index 2413335..178b7e7 100644 --- a/vendor/github.com/hashicorp/terraform/helper/shadow/value.go +++ b/vendor/github.com/hashicorp/terraform/helper/shadow/value.go | |||
@@ -26,6 +26,14 @@ type Value struct { | |||
26 | valueSet bool | 26 | valueSet bool |
27 | } | 27 | } |
28 | 28 | ||
29 | func (v *Value) Lock() { | ||
30 | v.lock.Lock() | ||
31 | } | ||
32 | |||
33 | func (v *Value) Unlock() { | ||
34 | v.lock.Unlock() | ||
35 | } | ||
36 | |||
29 | // Close closes the value. This can never fail. For a definition of | 37 | // Close closes the value. This can never fail. For a definition of |
30 | // "close" see the struct docs. | 38 | // "close" see the struct docs. |
31 | func (w *Value) Close() error { | 39 | func (w *Value) Close() error { |