hashicorp / hashicorp/hcl

hcldec: how to use `block_attrs`?

Open
#670 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

I don't understand how I'm supposed to use the `block_attrs` spec, and there are no examples in the hcldec documentation.

If I use the spec file here:
```
object {
block_attrs {
block_type = "locals"
element_type = any
required = false
}
}
```

I'm trying to parse a `locals` block filled with random attributes such as the hcl file here:
```
locals {
foo = "bar"
}
```

the latest version of hcldec outputs the following error:
```
Error: Unsupported block type

on spec.hcl line 2, in object:
2: block_attrs {

Blocks of type "block_attrs" are not expected here.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the error with the provided spec.hcl and locals input, then read the hcldec documentation around block_attrs. Done means documenting valid block_attrs usage and including an example that parses a locals block containing arbitrary attributes.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.