terraform/configs
Martin Atkins f93f7e5b5c configs/configupgrade: Remove redundant list brackets
In early versions of Terraform where the interpolation language didn't
have any real list support, list brackets around a single string was the
signal to split the string on a special uuid separator to produce a list
just in time for processing, giving expressions like this:

    foo = ["${test_instance.foo.*.id}"]

Logically this is weird because it looks like it should produce a list
of lists of strings. When we added real list support in Terraform 0.7 we
retained support for this behavior by trimming off extra levels of list
during evaluation, and inadvertently continued relying on this notation
for correct type checking.

During the Terraform 0.10 line we fixed the type checker bugs (a few
remaining issues notwithstanding) so that it was finally possible to
use the more intuitive form:

    foo = "${test_instance.foo.*.id}"

...but we continued trimming off extra levels of list for backward
compatibility.

Terraform 0.12 finally removes that compatibility shim, causing redundant
list brackets to be interpreted as a list of lists.

This upgrade rule attempts to identify situations that are relying on the
old compatibility behavior and trim off the redundant extra brackets. It's
not possible to do this fully-generally using only static analysis, but
we can gather enough information through or partial type inference
mechanism here to deal with the most common situations automatically and
produce a TF-UPGRADE-TODO comment for more complex scenarios where the
user intent isn't decidable with only static analysis.

In particular, this handles by far the most common situation of wrapping
list brackets around a splat expression like the first example above.
After this and the other upgrade rules are applied, the first example
above will become:

    foo = test_instance.foo.*.id
2018-12-07 17:05:36 -08:00
..
configload command: Fix terraform init -from-module with relative paths 2018-11-09 09:48:03 -08:00
configschema configs/configschema: Block.StaticValidateTraversal method 2018-11-26 08:25:03 -08:00
configupgrade configs/configupgrade: Remove redundant list brackets 2018-12-07 17:05:36 -08:00
test-fixtures configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
backend.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
compat_shim.go configs: Handle object constructor keys when shimming traversals 2018-10-16 18:49:20 -07:00
config.go various: helpers for collecting necessary provider types 2018-10-16 18:50:29 -07:00
config_build.go configs: use addrs.Module for module path, rather than []string 2018-10-16 18:46:46 -07:00
config_build_test.go configs/configload: package for loading configurations 2018-02-15 15:56:38 -08:00
config_test.go various: helpers for collecting necessary provider types 2018-10-16 18:50:29 -07:00
depends_on.go configs: quoted keywords/references are warnings, not errors 2018-02-15 15:56:39 -08:00
doc.go configs: Additional guidance in doc.go 2018-02-15 15:56:39 -08:00
module.go configs: Allow looking up resources by resource addresses. 2018-10-16 18:46:46 -07:00
module_call.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
module_call_test.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
module_merge.go configs: Re-unify the ManagedResource and DataResource types 2018-10-16 18:44:26 -07:00
module_merge_body.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
module_merge_test.go configs: allow full type constraints for variables 2018-03-08 16:23:35 -08:00
named_values.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
parser.go command: 0.12upgrade command 2018-10-16 18:50:29 -07:00
parser_config.go configs: allow full type constraints for variables 2018-03-08 16:23:35 -08:00
parser_config_dir.go configload: Configuration snapshots 2018-10-16 18:50:29 -07:00
parser_config_dir_test.go configs: record the source directory for modules 2018-10-16 18:46:46 -07:00
parser_config_test.go Fix tests after upgrading hcl 2018-11-26 23:38:37 +00:00
parser_test.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
parser_values.go configs: Parser.LoadValuesFile 2018-02-15 15:56:37 -08:00
parser_values_test.go configs: update values file invalid syntax test for new HCL behavior 2018-03-08 11:17:39 -08:00
provider.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
provider_test.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
provisioner.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
provisioneronfailure_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
provisionerwhen_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
resource.go configs: Reserve various names for future use 2018-11-26 08:25:03 -08:00
synth_body.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
synth_body_test.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
util.go configs: allow overrides files to omit args that primary files can't 2018-02-15 15:56:38 -08:00
variable_type_hint.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
variabletypehint_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
version_constraint.go configs: Parser.LoadConfigFile 2018-02-15 15:56:37 -08:00