outsideris / citizen

A Private Terraform Module/Provider Registry
Mozilla Public License 2.0
625 stars 84 forks source link

Support for terraform 0.12 #42

Closed tnijboer closed 3 years ago

tnijboer commented 5 years ago

At the moment if you want to push a 0.12 module you get the following error:

{"level":50,"time":1558622848948,"msg":"Malformed HCL","pid":7,"hostname":"citizen-68f58c75c9-9kxkb","name":"citizen","type":"Error","stack":"Error: Malformed HCL\n at Object.parse (/www/node_modules/gopher-hcl/index.js:28:25)\n at hclToJson (/www/lib/util.js:31:20)\n at <anonymous>","offset":34,"line":2,"column":17,"v":1} {"level":50,"time":1558622848949,"msg":"Error: Malformed HCL\n at Object.parse (/www/node_modules/gopher-hcl/index.js:28:25)\n at hclToJson (/www/lib/util.js:31:20)\n at <anonymous>","pid":7,"hostname":"citizen-68f58c75c9-9kxkb","name":"citizen","v":1}

I have looked at the node packages, it uses gopher-hcl (not updated since 22 Apr 2017) which uses the node HCL package which isn't updated since 18 Sep 2014.

the node HCL package is a port of https://github.com/hashicorp/hcl but I don't know how I can port it to the newest HCL version.

So how to proceed?

outsideris commented 5 years ago

Ok, I will check it. I didn't migrate my terraform environment yet.

robburger commented 5 years ago

I wouldn't normally link to a personal fork, but I managed to resolve this here: https://github.com/robburger/citizen/pull/5 and build a working Docker Hub image (that we use in our live environment.)

Disclaimer and reasoning: this is entirely a hack to make it work. Apologies for all the changes; I wasn't planning on making a PR to upstream due to the "hackiness", so I let my linter do some work. The real change is in lib/util.js and associated specs/tests.

I'm working on porting the idea to native go, but if there's enough interest here, I'll clean up and submit a PR here with just the required code changes.

richardgavel commented 4 years ago

I wonder how hard it would be to just introduce an environment or command line flag in citizen itself to skip the HCL check. One other thing: would HCL1 break an HCL2 parser (you often have to make changes in TF files to get them to validate in TF 0.12, but I don't know if that's a TF thing or an HCL2 thing.