terraform/configs/configupgrade
Martin Atkins 954d38e870 lang: New file-hashing functions
In prior versions, we recommended using hash functions in conjunction with
the file function as an idiom for detecting changes to upstream blobs
without fetching and comparing the whole blob.

That approach relied on us being able to return raw binary data from
file(...). Since Terraform strings pass through intermediate
representations that are not binary-safe (e.g. the JSON state), there was
a risk of string corruption in prior versions which we have avoided for
0.12 by requiring that file(...) be used only with UTF-8 text files.

The specific case of returning a string and immediately passing it into
another function was not actually subject to that corruption risk, since
the HIL interpreter would just pass the string through verbatim, but this
is still now forbidden as a result of the stricter handling of file(...).

To avoid breaking these use-cases, here we introduce variants of the hash
functions a with "file" prefix that take a filename for a disk file to
hash rather than hashing the given string directly. The configuration
upgrade tool also now includes a rule to detect the documented idiom and
rewrite it into a single function call for one of these new functions.

This does cause a bit of function sprawl, but that seems preferable to
introducing more complex rules for when file(...) can and cannot read
binary files, making the behavior of these various functions easier to
understand in isolation.
2019-01-25 10:18:44 -08:00
..
test-fixtures lang: New file-hashing functions 2019-01-25 10:18:44 -08:00
analysis.go configs/configupgrade: Do type inference with input variables 2018-12-07 17:05:36 -08:00
analysis_expr.go configs/configupgrade: Do type inference with input variables 2018-12-07 17:05:36 -08:00
doc.go configupgrade: new package for upgrading configs for 0.12 2018-10-16 18:50:29 -07:00
module_sources.go configupgrade: Load source code for a module and detect already upgraded 2018-10-16 18:50:29 -07:00
module_sources_test.go configupgrade: Load source code for a module and detect already upgraded 2018-10-16 18:50:29 -07:00
upgrade.go configs/configupgrade: Retain any .tf.json files unchanged 2018-12-04 11:37:39 -08:00
upgrade_body.go configs/configupgrade: Remove redundant list brackets 2018-12-07 17:05:36 -08:00
upgrade_expr.go lang: New file-hashing functions 2019-01-25 10:18:44 -08:00
upgrade_native.go configs/configupgrade: Pass through connection and provisioner blocks 2018-12-05 10:25:01 -08:00
upgrade_test.go configs/configupgrade: Remove redundant list brackets 2018-12-07 17:05:36 -08:00
upgrader.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00