diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/configs/configschema/decoder_spec.go | 14 |
1 files changed, 11 insertions, 3 deletions
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: |