Commit Graph

12 Commits

Author SHA1 Message Date
Megan Marsh 0993c976fa
hcl2_upgrade escaped quotes fix (#10794)
* clean up extra quoting that can cause text template failures. when everyone else abandons you, regex will always be there.

* LINTING
2021-03-22 10:56:30 +01:00
Megan Marsh a40a782408 remove escaped dir 2021-03-19 09:28:30 -07:00
Adrien Delorme e2e6bce4c4 Update hcl2_upgrade_test.go
show diffs with strings
2021-03-19 13:56:41 +01:00
sylviamoss 5ccbd27b72 Improve upgrade error and transform all variables with template eng to locals 2021-02-23 16:51:13 +01:00
sylviamoss a1a5cf0113 upgrade variables with other variables 2021-02-22 17:16:19 +01:00
sylviamoss 2016d6baec Fix panic on upgrading variables json file 2021-02-22 16:07:37 +01:00
Sylvia Moss e0557f84e9
Add access config to generated amazon ami data source (#10634) 2021-02-15 17:35:03 +01:00
sylviamoss 76e3d57cae add with-annotation flag to hcl2_upgrade 2021-02-12 15:18:53 +01:00
Sylvia Moss 774c5903f6
Add error-cleanup-provisioner to HCL2 (#10604) 2021-02-11 10:23:15 +01:00
Sylvia Moss d28e6fe009
write timestamp local only when necessary (#10602) 2021-02-10 14:54:19 +01:00
Sylvia Moss f5006d0842
fix empty locals and source name with blank space (#10593) 2021-02-09 14:57:42 +01:00
Adrien Delorme 5ba134ac5b
JSON to HCL2 (minimal best-effort) transpiler (#9659)
hcl2_upgrade transforms a JSON build-file in a HCL2 build-file.
This starts a validated Packer core and from that core we generate an HCL 'block' per plugin/configuration. So for a builder, a provisioner, a post-processor or a variable. The contents of each block is just transformed as is and basically all fields are HCL2-ified.
A generated field can be valid in JSON but invalid on HCL2; for example JSON templating (in mapstructure) allows to set arrays of strings - like `x = ["a", "b"]` - with single strings - like `x="a"` -, HCL does not allow this.
Since JSON does not make the distinction between variables and locals, everything will be a variable. So variables that use other variables will not work.
hcl2_upgrade tries to transform go templating interpolation calls to HCL2 calls when possible, leaving the go templating calls like they are in case it cannot.

Work:
* transpiler
* tests
* update hcl v2 library so that output looks great.
* update docs
2020-08-25 10:51:43 +02:00