jkcfg / jk

Configuration as Code with ECMAScript
https://jkcfg.github.io
Apache License 2.0
406 stars 30 forks source link

Fix terraform example to at least work with 0.11 terraform #313

Closed drubin closed 4 years ago

drubin commented 4 years ago

This references the bigger issue #312 and only makes it work with 0.11 terraform. I think we need to fix the upstream lib to get it to work with 0.12 considering they are dropping support for 0.11 I think it makes sense for this library to only support 0.12 going forward.

References #312

drubin commented 4 years ago

I suggest merge and squashing if yo u can I only just fixed the eslint warnings to my phone so the commits aren't great yet.

Edit: you were too quick

dlespiau commented 4 years ago

I’m not sure what’s upstream plan with the Hcl library but it seems likely they’ll accept changes to make the hcl serialisation compatible with 0.12

drubin commented 4 years ago

I tried to also fix the help text to highlight this only works with Terraform 0.11 but honestly I couldn't figure out how the docs are autogenerated from these. .cmd files (which is the coolest thing I have seen in a long time. Unit testing your example docs ++)

drubin commented 4 years ago

@dlespiau seems like we should just switch to the v2 branch https://github.com/hashicorp/hcl/wiki/Version-Selection

dlespiau commented 4 years ago

Oh, yes, indeed! Seems like we should bump our usage of the Hcl library to v2 and see what happens.

squaremo commented 4 years ago

we should bump our usage of the Hcl library to v2 and see what happens

I gave this a try. The v2 codebase is organised quite differently; I was able to find the package for parsing a JSON input (github.com/hashicorp/hcl/v2/hclparse), but there doesn't seem to be any general-purpose way to serialise the result into HCL. The most obvious candidate, .../hclwrite, seems to support only serialising values constructed in its own, disjoint set of types.