aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/zclconf/go-cty/cty/convert/conversion.go')
-rw-r--r--vendor/github.com/zclconf/go-cty/cty/convert/conversion.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/zclconf/go-cty/cty/convert/conversion.go b/vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
index 7bfcc08..f9aacb4 100644
--- a/vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
+++ b/vendor/github.com/zclconf/go-cty/cty/convert/conversion.go
@@ -17,6 +17,10 @@ func getConversion(in cty.Type, out cty.Type, unsafe bool) conversion {
17 // Wrap the conversion in some standard checks that we don't want to 17 // Wrap the conversion in some standard checks that we don't want to
18 // have to repeat in every conversion function. 18 // have to repeat in every conversion function.
19 return func(in cty.Value, path cty.Path) (cty.Value, error) { 19 return func(in cty.Value, path cty.Path) (cty.Value, error) {
20 if out == cty.DynamicPseudoType {
21 // Conversion to DynamicPseudoType always just passes through verbatim.
22 return in, nil
23 }
20 if !in.IsKnown() { 24 if !in.IsKnown() {
21 return cty.UnknownVal(out), nil 25 return cty.UnknownVal(out), nil
22 } 26 }
@@ -57,6 +61,12 @@ func getConversionKnown(in cty.Type, out cty.Type, unsafe bool) conversion {
57 } 61 }
58 return nil 62 return nil
59 63
64 case out.IsObjectType() && in.IsObjectType():
65 return conversionObjectToObject(in, out, unsafe)
66
67 case out.IsTupleType() && in.IsTupleType():
68 return conversionTupleToTuple(in, out, unsafe)
69
60 case out.IsListType() && (in.IsListType() || in.IsSetType()): 70 case out.IsListType() && (in.IsListType() || in.IsSetType()):
61 inEty := in.ElementType() 71 inEty := in.ElementType()
62 outEty := out.ElementType() 72 outEty := out.ElementType()
@@ -93,10 +103,23 @@ func getConversionKnown(in cty.Type, out cty.Type, unsafe bool) conversion {
93 } 103 }
94 return conversionCollectionToSet(outEty, convEty) 104 return conversionCollectionToSet(outEty, convEty)
95 105
106 case out.IsMapType() && in.IsMapType():
107 inEty := in.ElementType()
108 outEty := out.ElementType()
109 convEty := getConversion(inEty, outEty, unsafe)
110 if convEty == nil {
111 return nil
112 }
113 return conversionCollectionToMap(outEty, convEty)
114
96 case out.IsListType() && in.IsTupleType(): 115 case out.IsListType() && in.IsTupleType():
97 outEty := out.ElementType() 116 outEty := out.ElementType()
98 return conversionTupleToList(in, outEty, unsafe) 117 return conversionTupleToList(in, outEty, unsafe)
99 118
119 case out.IsSetType() && in.IsTupleType():
120 outEty := out.ElementType()
121 return conversionTupleToSet(in, outEty, unsafe)
122
100 case out.IsMapType() && in.IsObjectType(): 123 case out.IsMapType() && in.IsObjectType():
101 outEty := out.ElementType() 124 outEty := out.ElementType()
102 return conversionObjectToMap(in, outEty, unsafe) 125 return conversionObjectToMap(in, outEty, unsafe)