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 WIP 2020-07-02 15:56:49 +02:00
repl packer console for HCL2 (#9359) 2020-06-05 17:23:54 +02:00
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 Hcl2 input variables, local variables and functions (#8588) 2020-02-06 11:49:21 +01:00
docs.go Hcl2 input variables, local variables and functions (#8588) 2020-02-06 11:49:21 +01:00
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 build using HCL2 (#8423) 2019-12-17 11:25:56 +01:00
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 avoid passing generatedVars down during first prepare 2020-07-06 15:14:17 +02:00
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 Hcl2 input variables, local variables and functions (#8588) 2020-02-06 11:49:21 +01:00
types.kv.go make sure keyvalue and namevalue filters are using the same naming as the service being used 2020-04-16 17:22:13 +02:00
types.kv.hcl2spec.go HCL2: generate hcl tags with go-cty tags too (#9306) 2020-05-28 11:19:00 +02:00
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 pass source name from local source name too 2020-07-06 16:07:29 +02:00
types.source_test.go Allow to override some source fields from the build section 2020-05-25 17:09:37 +02:00
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 packer console for HCL2 (#9359) 2020-06-05 17:23:54 +02:00