packer-cn/hcl2template
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
..
function Use common funcs / fix panic / clarify docs 2020-08-12 22:34:13 +01:00
internal
repl
shim JSON to HCL2 (minimal best-effort) transpiler (#9659) 2020-08-25 10:51:43 +02:00
testdata Make max_retries a string to allow variable interpolation (#9673) 2020-08-05 17:41:20 +02:00
common_test.go refactor initialization out from packer configs + tests (#9627) 2020-07-24 10:58:03 +02:00
decode.go
docs.go
functions.go Add vault function for HCL2 and document 2020-08-11 09:18:15 +01:00
parser.go Make max_retries a string to allow variable interpolation (#9673) 2020-08-05 17:41:20 +02:00
types.build.from.go
types.build.go Make max_retries a string to allow variable interpolation (#9673) 2020-08-05 17:41:20 +02:00
types.build.post-processor.go
types.build.provisioners.go implemet override provisioner's option for hcl2 2020-08-13 19:27:04 +02:00
types.build_test.go HCL2: add post-processors block to run multiple post-processor after a build (#9638) 2020-07-28 10:02:37 +02:00
types.hcl_post-processor.go fix docker-import postprocessor. 2020-07-29 14:59:50 -07:00
types.hcl_provisioner.go implemet override provisioner's option for hcl2 2020-08-13 19:27:04 +02:00
types.hcl_ref.go
types.kv.go
types.kv.hcl2spec.go
types.packer_config.go HCL2: add post-processors block to run multiple post-processor after a build (#9638) 2020-07-28 10:02:37 +02:00
types.packer_config_test.go HCL2: add post-processors block to run multiple post-processor after a build (#9638) 2020-07-28 10:02:37 +02:00
types.source.go
types.source_test.go
types.variables.go refactor initialization out from packer configs + tests (#9627) 2020-07-24 10:58:03 +02:00
types.variables_test.go Make max_retries a string to allow variable interpolation (#9673) 2020-08-05 17:41:20 +02:00
utils.go