hcl2json icon indicating copy to clipboard operation
hcl2json copied to clipboard

tftest.hcl command conversion

Open konradzagozda opened this issue 1 year ago • 1 comments

I have file with test sth.tftest.hcl:

run "test_nothing" {
    command = plan
}

I attempt to convert it to json: and i get:

{
  "run": {
    "test_nothing": [
      {
        "command": "${plan}"
      }
    ]
  },
}

when I try to run terraform test on first version it's fine but when i try to run it on json version it errors with:

│ Error: Invalid "command" keyword
│ 
│   on tests-out/sth.tftest.json line 5, in run.test_nothing[0]:
│    5:         "command": "${plan}"
│ 
│ The "command" argument requires one of the following keywords without
│ quotes: apply or plan.

Is this hcl2json conversion issue or terraform issue?

konradzagozda avatar Dec 01 '24 00:12 konradzagozda

It's a "accurately converting hcl to json in all cases requires knowledge of the schema" problem.

This is basically the same problem as https://github.com/tmccombs/hcl2json/issues/12

tmccombs avatar Dec 01 '24 03:12 tmccombs