aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/config
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/config')
-rw-r--r--vendor/github.com/hashicorp/terraform/config/config.go29
-rw-r--r--vendor/github.com/hashicorp/terraform/config/interpolate_walk.go7
-rw-r--r--vendor/github.com/hashicorp/terraform/config/loader.go15
-rw-r--r--vendor/github.com/hashicorp/terraform/config/module/versions.go34
-rw-r--r--vendor/github.com/hashicorp/terraform/config/providers.go42
-rw-r--r--vendor/github.com/hashicorp/terraform/config/raw_config.go6
6 files changed, 38 insertions, 95 deletions
diff --git a/vendor/github.com/hashicorp/terraform/config/config.go b/vendor/github.com/hashicorp/terraform/config/config.go
index 1772fd7..f13a046 100644
--- a/vendor/github.com/hashicorp/terraform/config/config.go
+++ b/vendor/github.com/hashicorp/terraform/config/config.go
@@ -252,35 +252,6 @@ func (r *Resource) Id() string {
252 } 252 }
253} 253}
254 254
255// ProviderFullName returns the full name of the provider for this resource,
256// which may either be specified explicitly using the "provider" meta-argument
257// or implied by the prefix on the resource type name.
258func (r *Resource) ProviderFullName() string {
259 return ResourceProviderFullName(r.Type, r.Provider)
260}
261
262// ResourceProviderFullName returns the full (dependable) name of the
263// provider for a hypothetical resource with the given resource type and
264// explicit provider string. If the explicit provider string is empty then
265// the provider name is inferred from the resource type name.
266func ResourceProviderFullName(resourceType, explicitProvider string) string {
267 if explicitProvider != "" {
268 // check for an explicit provider name, or return the original
269 parts := strings.SplitAfter(explicitProvider, "provider.")
270 return parts[len(parts)-1]
271 }
272
273 idx := strings.IndexRune(resourceType, '_')
274 if idx == -1 {
275 // If no underscores, the resource name is assumed to be
276 // also the provider name, e.g. if the provider exposes
277 // only a single resource of each type.
278 return resourceType
279 }
280
281 return resourceType[:idx]
282}
283
284// Validate does some basic semantic checking of the configuration. 255// Validate does some basic semantic checking of the configuration.
285func (c *Config) Validate() tfdiags.Diagnostics { 256func (c *Config) Validate() tfdiags.Diagnostics {
286 if c == nil { 257 if c == nil {
diff --git a/vendor/github.com/hashicorp/terraform/config/interpolate_walk.go b/vendor/github.com/hashicorp/terraform/config/interpolate_walk.go
index 66a677d..ce33ab1 100644
--- a/vendor/github.com/hashicorp/terraform/config/interpolate_walk.go
+++ b/vendor/github.com/hashicorp/terraform/config/interpolate_walk.go
@@ -7,6 +7,7 @@ import (
7 7
8 "github.com/hashicorp/hil" 8 "github.com/hashicorp/hil"
9 "github.com/hashicorp/hil/ast" 9 "github.com/hashicorp/hil/ast"
10 "github.com/hashicorp/terraform/config/hcl2shim"
10 "github.com/mitchellh/reflectwalk" 11 "github.com/mitchellh/reflectwalk"
11) 12)
12 13
@@ -160,7 +161,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
160 if w.loc == reflectwalk.SliceElem { 161 if w.loc == reflectwalk.SliceElem {
161 switch typedReplaceVal := replaceVal.(type) { 162 switch typedReplaceVal := replaceVal.(type) {
162 case string: 163 case string:
163 if typedReplaceVal == UnknownVariableValue { 164 if typedReplaceVal == hcl2shim.UnknownVariableValue {
164 remove = true 165 remove = true
165 } 166 }
166 case []interface{}: 167 case []interface{}:
@@ -168,7 +169,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
168 remove = true 169 remove = true
169 } 170 }
170 } 171 }
171 } else if replaceVal == UnknownVariableValue { 172 } else if replaceVal == hcl2shim.UnknownVariableValue {
172 remove = true 173 remove = true
173 } 174 }
174 175
@@ -224,7 +225,7 @@ func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
224func hasUnknownValue(variable []interface{}) bool { 225func hasUnknownValue(variable []interface{}) bool {
225 for _, value := range variable { 226 for _, value := range variable {
226 if strVal, ok := value.(string); ok { 227 if strVal, ok := value.(string); ok {
227 if strVal == UnknownVariableValue { 228 if strVal == hcl2shim.UnknownVariableValue {
228 return true 229 return true
229 } 230 }
230 } 231 }
diff --git a/vendor/github.com/hashicorp/terraform/config/loader.go b/vendor/github.com/hashicorp/terraform/config/loader.go
index 6e34781..612e25b 100644
--- a/vendor/github.com/hashicorp/terraform/config/loader.go
+++ b/vendor/github.com/hashicorp/terraform/config/loader.go
@@ -135,21 +135,6 @@ func LoadDir(root string) (*Config, error) {
135 return result, nil 135 return result, nil
136} 136}
137 137
138// IsEmptyDir returns true if the directory given has no Terraform
139// configuration files.
140func IsEmptyDir(root string) (bool, error) {
141 if _, err := os.Stat(root); err != nil && os.IsNotExist(err) {
142 return true, nil
143 }
144
145 fs, os, err := dirFiles(root)
146 if err != nil {
147 return false, err
148 }
149
150 return len(fs) == 0 && len(os) == 0, nil
151}
152
153// Ext returns the Terraform configuration extension of the given 138// Ext returns the Terraform configuration extension of the given
154// path, or a blank string if it is an invalid function. 139// path, or a blank string if it is an invalid function.
155func ext(path string) string { 140func ext(path string) string {
diff --git a/vendor/github.com/hashicorp/terraform/config/module/versions.go b/vendor/github.com/hashicorp/terraform/config/module/versions.go
index 8348d4b..29701b9 100644
--- a/vendor/github.com/hashicorp/terraform/config/module/versions.go
+++ b/vendor/github.com/hashicorp/terraform/config/module/versions.go
@@ -3,7 +3,9 @@ package module
3import ( 3import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 "regexp"
6 "sort" 7 "sort"
8 "strings"
7 9
8 version "github.com/hashicorp/go-version" 10 version "github.com/hashicorp/go-version"
9 "github.com/hashicorp/terraform/registry/response" 11 "github.com/hashicorp/terraform/registry/response"
@@ -11,6 +13,8 @@ import (
11 13
12const anyVersion = ">=0.0.0" 14const anyVersion = ">=0.0.0"
13 15
16var explicitEqualityConstraint = regexp.MustCompile("^=[0-9]")
17
14// return the newest version that satisfies the provided constraint 18// return the newest version that satisfies the provided constraint
15func newest(versions []string, constraint string) (string, error) { 19func newest(versions []string, constraint string) (string, error) {
16 if constraint == "" { 20 if constraint == "" {
@@ -21,6 +25,30 @@ func newest(versions []string, constraint string) (string, error) {
21 return "", err 25 return "", err
22 } 26 }
23 27
28 // Find any build metadata in the constraints, and
29 // store whether the constraint is an explicit equality that
30 // contains a build metadata requirement, so we can return a specific,
31 // if requested, build metadata version
32 var constraintMetas []string
33 var equalsConstraint bool
34 for i := range cs {
35 constraintMeta := strings.SplitAfterN(cs[i].String(), "+", 2)
36 if len(constraintMeta) > 1 {
37 constraintMetas = append(constraintMetas, constraintMeta[1])
38 }
39 }
40
41 if len(cs) == 1 {
42 equalsConstraint = explicitEqualityConstraint.MatchString(cs.String())
43 }
44
45 // If the version string includes metadata, this is valid in go-version,
46 // However, it's confusing as to what expected behavior should be,
47 // so give an error so the user can do something more logical
48 if (len(cs) > 1 || !equalsConstraint) && len(constraintMetas) > 0 {
49 return "", fmt.Errorf("Constraints including build metadata must have explicit equality, or are otherwise too ambiguous: %s", cs.String())
50 }
51
24 switch len(versions) { 52 switch len(versions) {
25 case 0: 53 case 0:
26 return "", errors.New("no versions found") 54 return "", errors.New("no versions found")
@@ -58,6 +86,12 @@ func newest(versions []string, constraint string) (string, error) {
58 continue 86 continue
59 } 87 }
60 if cs.Check(v) { 88 if cs.Check(v) {
89 // Constraint has metadata and is explicit equality
90 if equalsConstraint && len(constraintMetas) > 0 {
91 if constraintMetas[0] != v.Metadata() {
92 continue
93 }
94 }
61 return versions[i], nil 95 return versions[i], nil
62 } 96 }
63 } 97 }
diff --git a/vendor/github.com/hashicorp/terraform/config/providers.go b/vendor/github.com/hashicorp/terraform/config/providers.go
index 7a50782..eeddabc 100644
--- a/vendor/github.com/hashicorp/terraform/config/providers.go
+++ b/vendor/github.com/hashicorp/terraform/config/providers.go
@@ -13,48 +13,6 @@ type ProviderVersionConstraint struct {
13// ProviderVersionConstraint, as produced by Config.RequiredProviders. 13// ProviderVersionConstraint, as produced by Config.RequiredProviders.
14type ProviderVersionConstraints map[string]ProviderVersionConstraint 14type ProviderVersionConstraints map[string]ProviderVersionConstraint
15 15
16// RequiredProviders returns the ProviderVersionConstraints for this
17// module.
18//
19// This includes both providers that are explicitly requested by provider
20// blocks and those that are used implicitly by instantiating one of their
21// resource types. In the latter case, the returned semver Range will
22// accept any version of the provider.
23func (c *Config) RequiredProviders() ProviderVersionConstraints {
24 ret := make(ProviderVersionConstraints, len(c.ProviderConfigs))
25
26 configs := c.ProviderConfigsByFullName()
27
28 // In order to find the *implied* dependencies (those without explicit
29 // "provider" blocks) we need to walk over all of the resources and
30 // cross-reference with the provider configs.
31 for _, rc := range c.Resources {
32 providerName := rc.ProviderFullName()
33 var providerType string
34
35 // Default to (effectively) no constraint whatsoever, but we might
36 // override if there's an explicit constraint in config.
37 constraint := ">=0.0.0"
38
39 config, ok := configs[providerName]
40 if ok {
41 if config.Version != "" {
42 constraint = config.Version
43 }
44 providerType = config.Name
45 } else {
46 providerType = providerName
47 }
48
49 ret[providerName] = ProviderVersionConstraint{
50 ProviderType: providerType,
51 Constraint: constraint,
52 }
53 }
54
55 return ret
56}
57
58// RequiredRanges returns a semver.Range for each distinct provider type in 16// RequiredRanges returns a semver.Range for each distinct provider type in
59// the constraint map. If the same provider type appears more than once 17// the constraint map. If the same provider type appears more than once
60// (e.g. because aliases are in use) then their respective constraints are 18// (e.g. because aliases are in use) then their respective constraints are
diff --git a/vendor/github.com/hashicorp/terraform/config/raw_config.go b/vendor/github.com/hashicorp/terraform/config/raw_config.go
index 1854a8b..c5ac86d 100644
--- a/vendor/github.com/hashicorp/terraform/config/raw_config.go
+++ b/vendor/github.com/hashicorp/terraform/config/raw_config.go
@@ -17,12 +17,6 @@ import (
17 "github.com/mitchellh/reflectwalk" 17 "github.com/mitchellh/reflectwalk"
18) 18)
19 19
20// UnknownVariableValue is a sentinel value that can be used
21// to denote that the value of a variable is unknown at this time.
22// RawConfig uses this information to build up data about
23// unknown keys.
24const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66"
25
26// RawConfig is a structure that holds a piece of configuration 20// RawConfig is a structure that holds a piece of configuration
27// where the overall structure is unknown since it will be used 21// where the overall structure is unknown since it will be used
28// to configure a plugin or some other similar external component. 22// to configure a plugin or some other similar external component.