aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/configs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/configs')
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/config_build.go1
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/configload/getter.go2
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/configload/loader_load.go10
-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
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/parser_config_dir.go21
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/resource.go32
-rw-r--r--vendor/github.com/hashicorp/terraform/configs/version_constraint.go7
8 files changed, 77 insertions, 20 deletions
diff --git a/vendor/github.com/hashicorp/terraform/configs/config_build.go b/vendor/github.com/hashicorp/terraform/configs/config_build.go
index 948b2c8..1ca1d77 100644
--- a/vendor/github.com/hashicorp/terraform/configs/config_build.go
+++ b/vendor/github.com/hashicorp/terraform/configs/config_build.go
@@ -76,6 +76,7 @@ func buildChildModules(parent *Config, walker ModuleWalker) (map[string]*Config,
76 } 76 }
77 77
78 child.Children, modDiags = buildChildModules(child, walker) 78 child.Children, modDiags = buildChildModules(child, walker)
79 diags = append(diags, modDiags...)
79 80
80 ret[call.Name] = child 81 ret[call.Name] = child
81 } 82 }
diff --git a/vendor/github.com/hashicorp/terraform/configs/configload/getter.go b/vendor/github.com/hashicorp/terraform/configs/configload/getter.go
index 4a3dace..75c7ef1 100644
--- a/vendor/github.com/hashicorp/terraform/configs/configload/getter.go
+++ b/vendor/github.com/hashicorp/terraform/configs/configload/getter.go
@@ -20,6 +20,7 @@ import (
20var goGetterDetectors = []getter.Detector{ 20var goGetterDetectors = []getter.Detector{
21 new(getter.GitHubDetector), 21 new(getter.GitHubDetector),
22 new(getter.BitBucketDetector), 22 new(getter.BitBucketDetector),
23 new(getter.GCSDetector),
23 new(getter.S3Detector), 24 new(getter.S3Detector),
24 new(getter.FileDetector), 25 new(getter.FileDetector),
25} 26}
@@ -44,6 +45,7 @@ var goGetterDecompressors = map[string]getter.Decompressor{
44 45
45var goGetterGetters = map[string]getter.Getter{ 46var goGetterGetters = map[string]getter.Getter{
46 "file": new(getter.FileGetter), 47 "file": new(getter.FileGetter),
48 "gcs": new(getter.GCSGetter),
47 "git": new(getter.GitGetter), 49 "git": new(getter.GitGetter),
48 "hg": new(getter.HgGetter), 50 "hg": new(getter.HgGetter),
49 "s3": new(getter.S3Getter), 51 "s3": new(getter.S3Getter),
diff --git a/vendor/github.com/hashicorp/terraform/configs/configload/loader_load.go b/vendor/github.com/hashicorp/terraform/configs/configload/loader_load.go
index 93a9420..0e6cba9 100644
--- a/vendor/github.com/hashicorp/terraform/configs/configload/loader_load.go
+++ b/vendor/github.com/hashicorp/terraform/configs/configload/loader_load.go
@@ -64,7 +64,15 @@ func (l *Loader) moduleWalkerLoad(req *configs.ModuleRequest) (*configs.Module,
64 Subject: &req.SourceAddrRange, 64 Subject: &req.SourceAddrRange,
65 }) 65 })
66 } 66 }
67 if !req.VersionConstraint.Required.Check(record.Version) { 67 if len(req.VersionConstraint.Required) > 0 && record.Version == nil {
68 diags = append(diags, &hcl.Diagnostic{
69 Severity: hcl.DiagError,
70 Summary: "Module version requirements have changed",
71 Detail: "The version requirements have changed since this module was installed and the installed version is no longer acceptable. Run \"terraform init\" to install all modules required by this configuration.",
72 Subject: &req.SourceAddrRange,
73 })
74 }
75 if record.Version != nil && !req.VersionConstraint.Required.Check(record.Version) {
68 diags = append(diags, &hcl.Diagnostic{ 76 diags = append(diags, &hcl.Diagnostic{
69 Severity: hcl.DiagError, 77 Severity: hcl.DiagError,
70 Summary: "Module version requirements have changed", 78 Summary: "Module version requirements have changed",
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:
diff --git a/vendor/github.com/hashicorp/terraform/configs/parser_config_dir.go b/vendor/github.com/hashicorp/terraform/configs/parser_config_dir.go
index 3014cb4..752d6d9 100644
--- a/vendor/github.com/hashicorp/terraform/configs/parser_config_dir.go
+++ b/vendor/github.com/hashicorp/terraform/configs/parser_config_dir.go
@@ -2,6 +2,7 @@ package configs
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os"
5 "path/filepath" 6 "path/filepath"
6 "strings" 7 "strings"
7 8
@@ -140,3 +141,23 @@ func IsIgnoredFile(name string) bool {
140 strings.HasSuffix(name, "~") || // vim 141 strings.HasSuffix(name, "~") || // vim
141 strings.HasPrefix(name, "#") && strings.HasSuffix(name, "#") // emacs 142 strings.HasPrefix(name, "#") && strings.HasSuffix(name, "#") // emacs
142} 143}
144
145// IsEmptyDir returns true if the given filesystem path contains no Terraform
146// configuration files.
147//
148// Unlike the methods of the Parser type, this function always consults the
149// real filesystem, and thus it isn't appropriate to use when working with
150// configuration loaded from a plan file.
151func IsEmptyDir(path string) (bool, error) {
152 if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
153 return true, nil
154 }
155
156 p := NewParser(nil)
157 fs, os, err := p.dirFiles(path)
158 if err != nil {
159 return false, err
160 }
161
162 return len(fs) == 0 && len(os) == 0, nil
163}
diff --git a/vendor/github.com/hashicorp/terraform/configs/resource.go b/vendor/github.com/hashicorp/terraform/configs/resource.go
index de1a343..edf822c 100644
--- a/vendor/github.com/hashicorp/terraform/configs/resource.go
+++ b/vendor/github.com/hashicorp/terraform/configs/resource.go
@@ -111,13 +111,15 @@ func decodeResourceBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
111 111
112 if attr, exists := content.Attributes["for_each"]; exists { 112 if attr, exists := content.Attributes["for_each"]; exists {
113 r.ForEach = attr.Expr 113 r.ForEach = attr.Expr
114 // We currently parse this, but don't yet do anything with it. 114 // Cannot have count and for_each on the same resource block
115 diags = append(diags, &hcl.Diagnostic{ 115 if r.Count != nil {
116 Severity: hcl.DiagError, 116 diags = append(diags, &hcl.Diagnostic{
117 Summary: "Reserved argument name in resource block", 117 Severity: hcl.DiagError,
118 Detail: fmt.Sprintf("The name %q is reserved for use in a future version of Terraform.", attr.Name), 118 Summary: `Invalid combination of "count" and "for_each"`,
119 Subject: &attr.NameRange, 119 Detail: `The "count" and "for_each" meta-arguments are mutually-exclusive, only one should be used to be explicit about the number of resources to be created.`,
120 }) 120 Subject: &attr.NameRange,
121 })
122 }
121 } 123 }
122 124
123 if attr, exists := content.Attributes["provider"]; exists { 125 if attr, exists := content.Attributes["provider"]; exists {
@@ -300,13 +302,15 @@ func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
300 302
301 if attr, exists := content.Attributes["for_each"]; exists { 303 if attr, exists := content.Attributes["for_each"]; exists {
302 r.ForEach = attr.Expr 304 r.ForEach = attr.Expr
303 // We currently parse this, but don't yet do anything with it. 305 // Cannot have count and for_each on the same data block
304 diags = append(diags, &hcl.Diagnostic{ 306 if r.Count != nil {
305 Severity: hcl.DiagError, 307 diags = append(diags, &hcl.Diagnostic{
306 Summary: "Reserved argument name in module block", 308 Severity: hcl.DiagError,
307 Detail: fmt.Sprintf("The name %q is reserved for use in a future version of Terraform.", attr.Name), 309 Summary: `Invalid combination of "count" and "for_each"`,
308 Subject: &attr.NameRange, 310 Detail: `The "count" and "for_each" meta-arguments are mutually-exclusive, only one should be used to be explicit about the number of resources to be created.`,
309 }) 311 Subject: &attr.NameRange,
312 })
313 }
310 } 314 }
311 315
312 if attr, exists := content.Attributes["provider"]; exists { 316 if attr, exists := content.Attributes["provider"]; exists {
diff --git a/vendor/github.com/hashicorp/terraform/configs/version_constraint.go b/vendor/github.com/hashicorp/terraform/configs/version_constraint.go
index 7aa19ef..e40ce16 100644
--- a/vendor/github.com/hashicorp/terraform/configs/version_constraint.go
+++ b/vendor/github.com/hashicorp/terraform/configs/version_constraint.go
@@ -45,6 +45,13 @@ func decodeVersionConstraint(attr *hcl.Attribute) (VersionConstraint, hcl.Diagno
45 return ret, diags 45 return ret, diags
46 } 46 }
47 47
48 if !val.IsWhollyKnown() {
49 // If there is a syntax error, HCL sets the value of the given attribute
50 // to cty.DynamicVal. A diagnostic for the syntax error will already
51 // bubble up, so we will move forward gracefully here.
52 return ret, diags
53 }
54
48 constraintStr := val.AsString() 55 constraintStr := val.AsString()
49 constraints, err := version.NewConstraint(constraintStr) 56 constraints, err := version.NewConstraint(constraintStr)
50 if err != nil { 57 if err != nil {