From 863486a6b71ed0e562a3965bed56465d007b1418 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Fri, 9 Aug 2019 15:59:15 +0200 Subject: update vendor and go.mod --- .../hashicorp/terraform/config/config.go | 29 --------------- .../hashicorp/terraform/config/interpolate_walk.go | 7 ++-- .../hashicorp/terraform/config/loader.go | 15 -------- .../hashicorp/terraform/config/module/versions.go | 34 ++++++++++++++++++ .../hashicorp/terraform/config/providers.go | 42 ---------------------- .../hashicorp/terraform/config/raw_config.go | 6 ---- 6 files changed, 38 insertions(+), 95 deletions(-) (limited to 'vendor/github.com/hashicorp/terraform/config') 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 { } } -// ProviderFullName returns the full name of the provider for this resource, -// which may either be specified explicitly using the "provider" meta-argument -// or implied by the prefix on the resource type name. -func (r *Resource) ProviderFullName() string { - return ResourceProviderFullName(r.Type, r.Provider) -} - -// ResourceProviderFullName returns the full (dependable) name of the -// provider for a hypothetical resource with the given resource type and -// explicit provider string. If the explicit provider string is empty then -// the provider name is inferred from the resource type name. -func ResourceProviderFullName(resourceType, explicitProvider string) string { - if explicitProvider != "" { - // check for an explicit provider name, or return the original - parts := strings.SplitAfter(explicitProvider, "provider.") - return parts[len(parts)-1] - } - - idx := strings.IndexRune(resourceType, '_') - if idx == -1 { - // If no underscores, the resource name is assumed to be - // also the provider name, e.g. if the provider exposes - // only a single resource of each type. - return resourceType - } - - return resourceType[:idx] -} - // Validate does some basic semantic checking of the configuration. func (c *Config) Validate() tfdiags.Diagnostics { 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 ( "github.com/hashicorp/hil" "github.com/hashicorp/hil/ast" + "github.com/hashicorp/terraform/config/hcl2shim" "github.com/mitchellh/reflectwalk" ) @@ -160,7 +161,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error { if w.loc == reflectwalk.SliceElem { switch typedReplaceVal := replaceVal.(type) { case string: - if typedReplaceVal == UnknownVariableValue { + if typedReplaceVal == hcl2shim.UnknownVariableValue { remove = true } case []interface{}: @@ -168,7 +169,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error { remove = true } } - } else if replaceVal == UnknownVariableValue { + } else if replaceVal == hcl2shim.UnknownVariableValue { remove = true } @@ -224,7 +225,7 @@ func (w *interpolationWalker) replaceCurrent(v reflect.Value) { func hasUnknownValue(variable []interface{}) bool { for _, value := range variable { if strVal, ok := value.(string); ok { - if strVal == UnknownVariableValue { + if strVal == hcl2shim.UnknownVariableValue { return true } } 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) { return result, nil } -// IsEmptyDir returns true if the directory given has no Terraform -// configuration files. -func IsEmptyDir(root string) (bool, error) { - if _, err := os.Stat(root); err != nil && os.IsNotExist(err) { - return true, nil - } - - fs, os, err := dirFiles(root) - if err != nil { - return false, err - } - - return len(fs) == 0 && len(os) == 0, nil -} - // Ext returns the Terraform configuration extension of the given // path, or a blank string if it is an invalid function. func 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 import ( "errors" "fmt" + "regexp" "sort" + "strings" version "github.com/hashicorp/go-version" "github.com/hashicorp/terraform/registry/response" @@ -11,6 +13,8 @@ import ( const anyVersion = ">=0.0.0" +var explicitEqualityConstraint = regexp.MustCompile("^=[0-9]") + // return the newest version that satisfies the provided constraint func newest(versions []string, constraint string) (string, error) { if constraint == "" { @@ -21,6 +25,30 @@ func newest(versions []string, constraint string) (string, error) { return "", err } + // Find any build metadata in the constraints, and + // store whether the constraint is an explicit equality that + // contains a build metadata requirement, so we can return a specific, + // if requested, build metadata version + var constraintMetas []string + var equalsConstraint bool + for i := range cs { + constraintMeta := strings.SplitAfterN(cs[i].String(), "+", 2) + if len(constraintMeta) > 1 { + constraintMetas = append(constraintMetas, constraintMeta[1]) + } + } + + if len(cs) == 1 { + equalsConstraint = explicitEqualityConstraint.MatchString(cs.String()) + } + + // If the version string includes metadata, this is valid in go-version, + // However, it's confusing as to what expected behavior should be, + // so give an error so the user can do something more logical + if (len(cs) > 1 || !equalsConstraint) && len(constraintMetas) > 0 { + return "", fmt.Errorf("Constraints including build metadata must have explicit equality, or are otherwise too ambiguous: %s", cs.String()) + } + switch len(versions) { case 0: return "", errors.New("no versions found") @@ -58,6 +86,12 @@ func newest(versions []string, constraint string) (string, error) { continue } if cs.Check(v) { + // Constraint has metadata and is explicit equality + if equalsConstraint && len(constraintMetas) > 0 { + if constraintMetas[0] != v.Metadata() { + continue + } + } return versions[i], nil } } 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 { // ProviderVersionConstraint, as produced by Config.RequiredProviders. type ProviderVersionConstraints map[string]ProviderVersionConstraint -// RequiredProviders returns the ProviderVersionConstraints for this -// module. -// -// This includes both providers that are explicitly requested by provider -// blocks and those that are used implicitly by instantiating one of their -// resource types. In the latter case, the returned semver Range will -// accept any version of the provider. -func (c *Config) RequiredProviders() ProviderVersionConstraints { - ret := make(ProviderVersionConstraints, len(c.ProviderConfigs)) - - configs := c.ProviderConfigsByFullName() - - // In order to find the *implied* dependencies (those without explicit - // "provider" blocks) we need to walk over all of the resources and - // cross-reference with the provider configs. - for _, rc := range c.Resources { - providerName := rc.ProviderFullName() - var providerType string - - // Default to (effectively) no constraint whatsoever, but we might - // override if there's an explicit constraint in config. - constraint := ">=0.0.0" - - config, ok := configs[providerName] - if ok { - if config.Version != "" { - constraint = config.Version - } - providerType = config.Name - } else { - providerType = providerName - } - - ret[providerName] = ProviderVersionConstraint{ - ProviderType: providerType, - Constraint: constraint, - } - } - - return ret -} - // RequiredRanges returns a semver.Range for each distinct provider type in // the constraint map. If the same provider type appears more than once // (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 ( "github.com/mitchellh/reflectwalk" ) -// UnknownVariableValue is a sentinel value that can be used -// to denote that the value of a variable is unknown at this time. -// RawConfig uses this information to build up data about -// unknown keys. -const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66" - // RawConfig is a structure that holds a piece of configuration // where the overall structure is unknown since it will be used // to configure a plugin or some other similar external component. -- cgit v1.2.3