open-policy-agent / conftest

Write tests against structured configuration data using the Open Policy Agent Rego query language
https://conftest.dev
Other
2.82k stars 298 forks source link

HCL2 example produces unmarshalling error #172

Closed princespaghetti closed 4 years ago

princespaghetti commented 4 years ago

when running the below command in the hcl2 example directory the following error is produced conftest test terraform.tf

ERRO[0000] Unable to BulkUnmarshal your config files: Should not have any errors on unmarshalling: At 16:16: Unknown token: 16:16 IDENT data.consul_key_prefix.environment.var

This seems to be an error parsing the terraform.tf file and how the parser handles the dynamic block.

Version in use: 0.15.0

princespaghetti commented 4 years ago

Can create a different issue if needed, but also noticed the repo referenced by the parser code for HCL2 has a disclaimer to point back to the main HCL repository: https://github.com/hashicorp/hcl2/#experimental-hcl2

boranx commented 4 years ago

Hi @barbia,

Normally tf extension strictly bound to classic hcl. To use hcl2, pass --input flag to the test command like:

conftest test --input hcl2 terraform.tf
princespaghetti commented 4 years ago

Thanks @boranx! Any thoughts on my second note, it sounds like the two libraries will be unifying at some point: https://github.com/hashicorp/hcl/wiki/Version-Selection

menendezjaume commented 4 years ago

Hey @boranx, @barbia,

I'd be happy to work on migrating our current parser to the stable version if that's something of interest to the project.

Thanks.

menendezjaume commented 4 years ago

I have raised a PR that should address this.

Blokje5 commented 4 years ago

@menendezjaume Thanks for providing a PR. I will close this issue.