aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/configs/configschema
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/configs/configschema')
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/configschema/coerce_value.go10
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go14
2 files changed, 19 insertions, 5 deletions
diff --git a/vendor/github.com/hashicorp/terraform/configs/configschema/coerce_value.go b/vendor/github.com/hashicorp/terraform/configs/configschema/coerce_value.go
index e59f58d..7996c38 100644
--- a/vendor/github.com/hashicorp/terraform/configs/configschema/coerce_value.go
+++ b/vendor/github.com/hashicorp/terraform/configs/configschema/coerce_value.go
@@ -113,7 +113,10 @@ func (b *Block) coerceValue(in cty.Value, path cty.Path) (cty.Value, error) {
113 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("must be a list") 113 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("must be a list")
114 } 114 }
115 l := coll.LengthInt() 115 l := coll.LengthInt()
116 if l < blockS.MinItems { 116
117 // Assume that if there are unknowns this could have come from
118 // a dynamic block, and we can't validate MinItems yet.
119 if l < blockS.MinItems && coll.IsWhollyKnown() {
117 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("insufficient items for attribute %q; must have at least %d", typeName, blockS.MinItems) 120 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("insufficient items for attribute %q; must have at least %d", typeName, blockS.MinItems)
118 } 121 }
119 if l > blockS.MaxItems && blockS.MaxItems > 0 { 122 if l > blockS.MaxItems && blockS.MaxItems > 0 {
@@ -161,7 +164,10 @@ func (b *Block) coerceValue(in cty.Value, path cty.Path) (cty.Value, error) {
161 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("must be a set") 164 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("must be a set")
162 } 165 }
163 l := coll.LengthInt() 166 l := coll.LengthInt()
164 if l < blockS.MinItems { 167
168 // Assume that if there are unknowns this could have come from
169 // a dynamic block, and we can't validate MinItems yet.
170 if l < blockS.MinItems && coll.IsWhollyKnown() {
165 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("insufficient items for attribute %q; must have at least %d", typeName, blockS.MinItems) 171 return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("insufficient items for attribute %q; must have at least %d", typeName, blockS.MinItems)
166 } 172 }
167 if l > blockS.MaxItems && blockS.MaxItems > 0 { 173 if l > blockS.MaxItems && blockS.MaxItems > 0 {
diff --git a/vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go b/vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go
index d8f41ea..e748dd2 100644
--- a/vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go
+++ b/vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go
@@ -33,6 +33,14 @@ func (b *Block) DecoderSpec() hcldec.Spec {
33 33
34 childSpec := blockS.Block.DecoderSpec() 34 childSpec := blockS.Block.DecoderSpec()
35 35
36 // We can only validate 0 or 1 for MinItems, because a dynamic block
37 // may satisfy any number of min items while only having a single
38 // block in the config.
39 minItems := 0
40 if blockS.MinItems > 1 {
41 minItems = 1
42 }
43
36 switch blockS.Nesting { 44 switch blockS.Nesting {
37 case NestingSingle, NestingGroup: 45 case NestingSingle, NestingGroup:
38 ret[name] = &hcldec.BlockSpec{ 46 ret[name] = &hcldec.BlockSpec{
@@ -57,14 +65,14 @@ func (b *Block) DecoderSpec() hcldec.Spec {
57 ret[name] = &hcldec.BlockTupleSpec{ 65 ret[name] = &hcldec.BlockTupleSpec{
58 TypeName: name, 66 TypeName: name,
59 Nested: childSpec, 67 Nested: childSpec,
60 MinItems: blockS.MinItems, 68 MinItems: minItems,
61 MaxItems: blockS.MaxItems, 69 MaxItems: blockS.MaxItems,
62 } 70 }
63 } else { 71 } else {
64 ret[name] = &hcldec.BlockListSpec{ 72 ret[name] = &hcldec.BlockListSpec{
65 TypeName: name, 73 TypeName: name,
66 Nested: childSpec, 74 Nested: childSpec,
67 MinItems: blockS.MinItems, 75 MinItems: minItems,
68 MaxItems: blockS.MaxItems, 76 MaxItems: blockS.MaxItems,
69 } 77 }
70 } 78 }
@@ -77,7 +85,7 @@ func (b *Block) DecoderSpec() hcldec.Spec {
77 ret[name] = &hcldec.BlockSetSpec{ 85 ret[name] = &hcldec.BlockSetSpec{
78 TypeName: name, 86 TypeName: name,
79 Nested: childSpec, 87 Nested: childSpec,
80 MinItems: blockS.MinItems, 88 MinItems: minItems,
81 MaxItems: blockS.MaxItems, 89 MaxItems: blockS.MaxItems,
82 } 90 }
83 case NestingMap: 91 case NestingMap: