Commit Graph

151 Commits

Author SHA1 Message Date
Paul Hinze 3f72837f4b core: Make copies when creating destroy nodes
Fixes an interpolation race that was occurring when a tainted destroy
node and a primary destroy node both tried to interpolate a computed
count in their config. Since they were sharing a pointer to the _same_
config, depending on how the race played out one of them could catch the
config uninterpolated and would then throw a syntax error.

The `Copy()` tree implemented for this fix can probably be used
elsewhere - basically we should copy the config whenever we drop nodes
into the graph - but for now I'm just applying it to the place that
fixes this bug.

Fixes #4982 - Includes a test covering that race condition.
2016-02-09 09:25:16 -06:00
James Nugent cb6cb8b96a core: Support explicit variable type declaration
This commit adds support for declaring variable types in Terraform
configuration. Historically, the type has been inferred from the default
value, defaulting to string if no default was supplied. This has caused
users to devise workarounds if they wanted to declare a map but provide
values from a .tfvars file (for example).

The new syntax adds the "type" key to variable blocks:

```
variable "i_am_a_string" {
    type = "string"
}

variable "i_am_a_map" {
    type = "map"
}
```

This commit does _not_ extend the type system to include bools, integers
or floats - the only two types available are maps and strings.

Validation is performed if a default value is provided in order to
ensure that the default value type matches the declared type.

In the case that a type is not declared, the old logic is used for
determining the type. This allows backwards compatiblity with previous
Terraform configuration.
2016-01-24 11:40:02 -06:00
Paul Hinze 87a9701f91 config: validation error when output is missing value field
Also lists out invalid keys in errmsg when they are present

Closes #4398
2016-01-20 14:00:36 -06:00
Mitchell Hashimoto 99fbb91ba2 config: validate lifecycle keys [GH-4413] 2016-01-19 11:28:45 -08:00
Paul Hinze b6626eed57 config: friendlier error message on resource arity mismatch
closes #2072
2015-12-09 18:05:49 -06:00
James Nugent 5ea25363a1 Add regression test for #4069
This may be brittle as it makes use of .gitattributes to override the
autocrlf setting in order to have an input file with Windows line
endings across multiple platforms.
2015-12-01 13:37:18 -05:00
Paul Hinze d90eb2d88e config: test replicating #4079
Should help cover terraform against regression once
https://github.com/hashicorp/hcl/pull/70 lands.
2015-12-01 10:31:05 -06:00
James Nugent 7f5f8d300d Add failing test replicating #4065 2015-11-26 15:08:48 +02:00
Paul Hinze afb5136ac2 Merge pull request #3986 from hashicorp/phinze/hcl-escaped-quotes
config: test covering escaped quotes syntax error
2015-11-19 12:32:30 -06:00
Paul Hinze 15e7927009 config: test covering escaped quotes syntax error
This was never intended to be valid syntax, but it worked in the old HCL
parser, and we've found a decent number of examples of it in the wild.

Fixed in https://github.com/hashicorp/hcl/pull/62 and we'll keep this
test in Terraform to cover the behavior.
2015-11-19 12:11:42 -06:00
James Nugent 6ae3218f8a Add failing tests for JSON configuration parsing
Reproduces the issue reported by @svanharmelen in #3964.
2015-11-19 16:06:30 +02:00
James Nugent f4164b5322 Add resource with heredoc to config load tests
This test reproduces the issue which is likely the root cause of #3840.
Test is currently failing with an "illegal character" message
corresponding with the location of the heredoc, which is also seen in
various acceptance tests for providers.
2015-11-10 18:12:21 -05:00
Rob Zienert a1939e70f7 Adding ignore_changes lifecycle meta property 2015-10-14 16:34:27 -05:00
Mitchell Hashimoto aa1e66c16c config: parse lifecycle block with mapstructure for weak decode 2015-06-07 22:04:23 -07:00
Mitchell Hashimoto cca4964552 config: error in validation if module has self variable 2015-04-22 10:39:07 +02:00
Mitchell Hashimoto d0a6d78b97 config: test that resources reference good providers 2015-04-20 14:47:31 -07:00
Mitchell Hashimoto 8ee18e2e14 config: happy case test for multiple providers 2015-04-20 14:27:44 -07:00
Mitchell Hashimoto a599d5f224 config: validate that a multi provider is only configured once each 2015-04-20 14:25:33 -07:00
Paul Hinze 975a96f271 core: protect against count.index in modules
Modules should get a validation error just like outputs do.

refs #1528
2015-04-15 10:41:56 -05:00
Paul Hinze 347690a73e core: don't crash when count.index is used in the wrong context
It's bad manners! :)

Also adds a validation error up at the configuration layer so the user
sees the case from #1528 as an error message.

fixes #1528
2015-04-15 10:23:53 -05:00
Mitchell Hashimoto fdded8ca14 config: allow atlas block 2015-03-24 13:30:22 -07:00
Radek Simko f794f30b7d Ignore hidden files per Unix conventions 2015-03-18 07:50:33 +00:00
Mitchell Hashimoto 965fe45b9e config: self var validation 2015-02-23 14:43:14 -08:00
Mitchell Hashimoto a31f2a276b Merge pull request #1015 from hashicorp/b-depends-on-var
config: depends on cannot contain interpolations [GH-985]
2015-02-23 13:49:34 -08:00
Mitchell Hashimoto c14e84a657 config: validate provisioner splats can only reference others 2015-02-20 09:21:29 -08:00
Mitchell Hashimoto f156d0d1bd config: test we can ref splat of other resources 2015-02-20 09:19:13 -08:00
Mitchell Hashimoto 90a6a627ed config: validate configuration doens't contain splats to ourselves 2015-02-20 09:18:08 -08:00
Mitchell Hashimoto 0e7b150c5b config: depends on cannot contain interpolations [GH-985] 2015-02-20 09:07:41 -08:00
Mitchell Hashimoto 4bcf6cf6b2 config: bare splat variables should not be allowed in provisioners
[GH-636]
2015-02-17 13:32:45 -08:00
Mitchell Hashimoto 91a3405e88 config: understand provisioner blocks in JSON [GH-807] 2015-01-16 10:14:48 -08:00
Mitchell Hashimoto a2e40ad731 config: multi-variable access in slice validation fixed [GH-798] 2015-01-15 09:40:13 -08:00
Mitchell Hashimoto d24082da1e config: validate that module variables can go to ints, convert [GH-624] 2014-12-15 22:10:16 -08:00
Kushal Pisavadia b40b7ce01a Do not read temporary editor files, fixes #548
This fixes a bug where Terraform would error with the following:

```
Error loading config: Error reading
/Users/rhenrichs/work/example/.#example.tf: open
/Users/rhenrichs/work/example/.#example.tf: no such file or directory
```

The solution implemented here ignores the common emacs and vim
temporary file formats.

Note: the potential danger with merging this is that Terraform could
quickly have requests to ignore other file formats.
2014-12-09 13:15:00 +00:00
Mitchell Hashimoto 4cb1ea6ae1 config: allow exact multi-resource references outside slices 2014-10-11 17:20:39 -07:00
Mitchell Hashimoto 7b48924532 config: validate that multi-variables are only used in slices 2014-10-09 21:15:08 -07:00
Mitchell Hashimoto 67d9188a29 config: validate module names are valid 2014-10-08 16:03:22 -07:00
Mitchell Hashimoto e922b16dba Merge pull request #377 from hashicorp/f-path-var
Add ${path.X} variables for path referencing
2014-10-07 21:26:24 -07:00
Mitchell Hashimoto c1fa4c2e4b config: validate that module source can't contain interpolations 2014-10-07 20:19:32 -07:00
Mitchell Hashimoto 679ab1d515 config: parse ${path.module} 2014-10-07 18:03:11 -07:00
Mitchell Hashimoto 2e63a69e57 config: validate good count variables 2014-10-02 18:25:18 -07:00
Mitchell Hashimoto b484ec19b6 config: validate that count vars are valid types 2014-10-02 18:24:37 -07:00
Mitchell Hashimoto bc26777963 config: count can't interpolate count variables 2014-10-02 18:22:32 -07:00
Mitchell Hashimoto dd14303022 config: validate that count is an int 2014-10-02 16:51:20 -07:00
Mitchell Hashimoto 5090678168 config: validate that only proper variables can be in the count 2014-10-02 16:30:46 -07:00
Mitchell Hashimoto 101ac636a2 config: add Config method 2014-10-02 11:34:08 -07:00
Mitchell Hashimoto f772c11103 config: validate unknown var in count 2014-10-02 11:18:57 -07:00
Armon Dadgar 1aaddafba0 terraform: Adding lifecycle config block 2014-09-29 15:20:02 -07:00
Armon Dadgar a14ea76c84 config: Support create_before_destroy config 2014-09-29 15:18:49 -07:00
Mitchell Hashimoto b60da29d48 config: validate that variables reference valid modules 2014-09-15 11:45:41 -07:00
Mitchell Hashimoto 4fdb6d1b52 config: add test for empty file 2014-09-15 09:41:00 -07:00
Mitchell Hashimoto 8dc8eac4bf config: change module syntax 2014-09-14 14:43:54 -07:00
Mitchell Hashimoto 610e92cab2 config: validate no duplicate modules 2014-09-11 16:02:36 -07:00
Mitchell Hashimoto 2a6990e2b9 config: `module` structures parse 2014-09-11 15:58:30 -07:00
Mitchell Hashimoto 21472e98b8 config: unit tests for lexer 2014-09-09 14:34:03 -07:00
Mitchell Hashimoto 038cca291e config: HCL loader 2014-08-11 09:58:53 -07:00
Mitchell Hashimoto fe2a306341 config: validate no interp in var [GH-180] 2014-08-11 09:46:56 -07:00
Mitchell Hashimoto d28e5a1638 dos2unix 2014-07-28 10:43:00 -07:00
Mitchell Hashimoto f9f4e62411 config: validate that count is >= 1 2014-07-26 14:49:55 -07:00
Mitchell Hashimoto fa175113fe config: case sensitive templates 2014-07-23 08:38:43 -07:00
Mitchell Hashimoto 20da842bcf config: validate dependsOn 2014-07-22 17:16:48 -07:00
Mitchell Hashimoto 0699cde1d4 config: depends_on meta-parameter 2014-07-22 17:10:17 -07:00
Mitchell Hashimoto b10b678326 config: fix error message in validation 2014-07-22 08:47:10 -07:00
Mitchell Hashimoto b8a0a02217 config: TODO tests for validation 2014-07-21 08:34:44 -07:00
Mitchell Hashimoto e396b8f3d9 config: test that multiple overrides work 2014-07-20 17:56:02 -07:00
Mitchell Hashimoto 06cdd4fa42 config: LoadDir loads override files 2014-07-20 17:52:46 -07:00
Mitchell Hashimoto cf1f3a9e73 config: test that LoadDir doesn't merge 2014-07-19 16:44:23 -07:00
Mitchell Hashimoto 9cd1018f0b config: config files can be in JSON, as well 2014-07-18 16:54:52 -07:00
Mitchell Hashimoto 50095612a2 config: resource should be unique 2014-07-18 16:31:01 -07:00
Mitchell Hashimoto 5329124cf9 config: unknown keys give errors 2014-07-18 16:00:21 -07:00
Armon Dadgar 2f2f5890f4 config: Testing loading of connection blocks 2014-07-15 12:34:06 -07:00
Mitchell Hashimoto 7a01e781ab config: LoadDir with no matching files errors 2014-07-11 21:04:59 -07:00
Mitchell Hashimoto 6dfebcae69 config: test that we only load tf files 2014-07-11 20:17:25 -07:00
Mitchell Hashimoto 8655711a3f config: test that LoadDir doesn't load nested 2014-07-11 20:16:49 -07:00
Mitchell Hashimoto 14b29d0ecd config: LoadDir 2014-07-11 20:15:09 -07:00
Mitchell Hashimoto e250a6f36c config: understand "provisioner" blocks 2014-07-10 11:38:55 -07:00
Mitchell Hashimoto aa6a758f6b config: if count > 1, variable references must have index
/cc @pearkes - Here is that validation
2014-07-06 13:46:56 -07:00
Mitchell Hashimoto ed1860de61 config: validate output only has "value" field 2014-07-04 10:57:09 -07:00
Mitchell Hashimoto a4f38a3933 config: validate resource variables in output 2014-07-04 10:53:36 -07:00
Mitchell Hashimoto cc2bb950a1 config: can parse outputs 2014-07-04 10:43:06 -07:00
Mitchell Hashimoto 5e79ddf7c6 config: detect variables in form of resource.name.*.blah 2014-07-03 20:41:26 -07:00
Mitchell Hashimoto 3337a625af config: support count meta-parameter 2014-07-03 20:11:58 -07:00
Mitchell Hashimoto 78e056770c config: validate that resource references are valid 2014-07-02 21:06:26 -07:00
Mitchell Hashimoto 532cc33189 config: semantic check on variable references 2014-07-02 21:01:03 -07:00
Mitchell Hashimoto e50425b182 config: style 2014-07-02 12:04:37 -07:00
Mitchell Hashimoto 7ab7ce17d9 config: tests passing for bug @pearkes found 2014-07-02 09:11:31 -07:00
Jack Pearkes d84c5fb015 config: fix libucl in test case (still failing) 2014-07-01 21:18:01 -07:00
Jack Pearkes bef1495c96 config: add failing test case for nested objects 2014-07-01 21:16:47 -07:00
Mitchell Hashimoto 46d3800a39 config: remove some unused test fixtures 2014-06-24 15:02:02 -07:00
Mitchell Hashimoto 867f6b3691 config: test to make sure that cycles are properly detected 2014-06-05 12:53:59 -07:00
Mitchell Hashimoto 3ccfd4d08c config: depgraph can contain provider configuratoins 2014-06-05 12:47:28 -07:00
Mitchell Hashimoto 0008ff12c7 config: determine whether a variable is required properly 2014-06-03 15:55:51 -07:00
Mitchell Hashimoto 9895f8162f config: unix line endings in tests 2014-05-30 17:38:35 -07:00
Mitchell Hashimoto ab507814b7 config: support for provider configs 2014-05-25 18:05:18 -07:00
Mitchell Hashimoto 81bfa8970a config: make the tests a bit more intense 2014-05-24 14:02:49 -07:00
Mitchell Hashimoto dac18c823a config: can generate depgraph 2014-05-24 13:57:51 -07:00
Mitchell Hashimoto 6983a0414a config: fix line endings on a test fixture 2014-05-24 11:44:48 -07:00
Mitchell Hashimoto 95ef186bf8 config: can detect variables in config strings 2014-05-23 21:58:06 -07:00
Mitchell Hashimoto 50830e429a config: merge resources 2014-05-23 16:25:54 -07:00
Mitchell Hashimoto aadb24aa08 config: error if unknown filetype 2014-05-23 15:42:29 -07:00
Mitchell Hashimoto 2ffee2a142 config: imports are relative to tf 2014-05-23 15:11:57 -07:00