diff options
author | Radek Simko <radek.simko@gmail.com> | 2017-08-14 16:10:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 16:10:17 +0200 |
commit | 00a66330be57dc8d7f987b4235d65d372f6b471f (patch) | |
tree | 864f925049d422033dd25a73bafce32b361c8827 /vendor/github.com/hashicorp/terraform/config/config.go | |
parent | b6a7c48445fdb87dcae46906aa7e9349209d8bb5 (diff) | |
parent | c680a8e1622ed0f18751d9d167c836ee24f5e897 (diff) | |
download | terraform-provider-statuscake-00a66330be57dc8d7f987b4235d65d372f6b471f.tar.gz terraform-provider-statuscake-00a66330be57dc8d7f987b4235d65d372f6b471f.tar.zst terraform-provider-statuscake-00a66330be57dc8d7f987b4235d65d372f6b471f.zip |
Merge pull request #3 from terraform-providers/vendor-tf-0.10
vendor: github.com/hashicorp/terraform/...@v0.10.0
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/config/config.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/config/config.go | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/vendor/github.com/hashicorp/terraform/config/config.go b/vendor/github.com/hashicorp/terraform/config/config.go index a157824..3f756dc 100644 --- a/vendor/github.com/hashicorp/terraform/config/config.go +++ b/vendor/github.com/hashicorp/terraform/config/config.go | |||
@@ -12,6 +12,7 @@ import ( | |||
12 | "github.com/hashicorp/hil" | 12 | "github.com/hashicorp/hil" |
13 | "github.com/hashicorp/hil/ast" | 13 | "github.com/hashicorp/hil/ast" |
14 | "github.com/hashicorp/terraform/helper/hilmapstructure" | 14 | "github.com/hashicorp/terraform/helper/hilmapstructure" |
15 | "github.com/hashicorp/terraform/plugin/discovery" | ||
15 | "github.com/mitchellh/reflectwalk" | 16 | "github.com/mitchellh/reflectwalk" |
16 | ) | 17 | ) |
17 | 18 | ||
@@ -64,6 +65,7 @@ type Module struct { | |||
64 | type ProviderConfig struct { | 65 | type ProviderConfig struct { |
65 | Name string | 66 | Name string |
66 | Alias string | 67 | Alias string |
68 | Version string | ||
67 | RawConfig *RawConfig | 69 | RawConfig *RawConfig |
68 | } | 70 | } |
69 | 71 | ||
@@ -238,6 +240,33 @@ func (r *Resource) Id() string { | |||
238 | } | 240 | } |
239 | } | 241 | } |
240 | 242 | ||
243 | // ProviderFullName returns the full name of the provider for this resource, | ||
244 | // which may either be specified explicitly using the "provider" meta-argument | ||
245 | // or implied by the prefix on the resource type name. | ||
246 | func (r *Resource) ProviderFullName() string { | ||
247 | return ResourceProviderFullName(r.Type, r.Provider) | ||
248 | } | ||
249 | |||
250 | // ResourceProviderFullName returns the full (dependable) name of the | ||
251 | // provider for a hypothetical resource with the given resource type and | ||
252 | // explicit provider string. If the explicit provider string is empty then | ||
253 | // the provider name is inferred from the resource type name. | ||
254 | func ResourceProviderFullName(resourceType, explicitProvider string) string { | ||
255 | if explicitProvider != "" { | ||
256 | return explicitProvider | ||
257 | } | ||
258 | |||
259 | idx := strings.IndexRune(resourceType, '_') | ||
260 | if idx == -1 { | ||
261 | // If no underscores, the resource name is assumed to be | ||
262 | // also the provider name, e.g. if the provider exposes | ||
263 | // only a single resource of each type. | ||
264 | return resourceType | ||
265 | } | ||
266 | |||
267 | return resourceType[:idx] | ||
268 | } | ||
269 | |||
241 | // Validate does some basic semantic checking of the configuration. | 270 | // Validate does some basic semantic checking of the configuration. |
242 | func (c *Config) Validate() error { | 271 | func (c *Config) Validate() error { |
243 | if c == nil { | 272 | if c == nil { |
@@ -349,7 +378,8 @@ func (c *Config) Validate() error { | |||
349 | } | 378 | } |
350 | } | 379 | } |
351 | 380 | ||
352 | // Check that providers aren't declared multiple times. | 381 | // Check that providers aren't declared multiple times and that their |
382 | // version constraints, where present, are syntactically valid. | ||
353 | providerSet := make(map[string]struct{}) | 383 | providerSet := make(map[string]struct{}) |
354 | for _, p := range c.ProviderConfigs { | 384 | for _, p := range c.ProviderConfigs { |
355 | name := p.FullName() | 385 | name := p.FullName() |
@@ -360,6 +390,16 @@ func (c *Config) Validate() error { | |||
360 | continue | 390 | continue |
361 | } | 391 | } |
362 | 392 | ||
393 | if p.Version != "" { | ||
394 | _, err := discovery.ConstraintStr(p.Version).Parse() | ||
395 | if err != nil { | ||
396 | errs = append(errs, fmt.Errorf( | ||
397 | "provider.%s: invalid version constraint %q: %s", | ||
398 | name, p.Version, err, | ||
399 | )) | ||
400 | } | ||
401 | } | ||
402 | |||
363 | providerSet[name] = struct{}{} | 403 | providerSet[name] = struct{}{} |
364 | } | 404 | } |
365 | 405 | ||