hashicorp / hashicorp/hcl

blocks and labels representation

Open
#301 3 comments 1 reaction 0 assignees View on GitHub
cmd/hcldec enhancement v2
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Hi !

Is it possible to write a schema so that the following representations are equivalent? (I looked at the way it is handled in Terraform, but I'm using another language so I would like to stick with something like `hcldec`).

```hcl
# terraform-like provisioning
provision "file" {
src = "foo"
dst = "/bar"
}

provision "exec" {
cmd = "/bar"
}
```

The label is used to internally tag the object with the `type` key, thus keeping the declaration order:

```json
{
"provision": [
{"type": "file", "src": "foo", "dst": "/bar"},
{"type": "exec", "cmd": "/bar"}
]
}
```

It would be a kind of enum-like block list.

Thanks !

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing hcldec and Terraform's handling of blocks and labels. Determine whether a schema can represent the proposed enum-like block list while preserving declaration order, and use the equivalent HCL and JSON examples in the issue as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
terraform
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.