hcl
hcl copied to clipboard
Add support for dynamic blocks when using ',remain' tag
Background:
We wanted a map[string]cty.Value
from HCL. We tried using a map
in cty
but that means all the values should be of the same type, e.g. this fails:
fields = {
my_bool = false
my_string = "string"
}
So we resorted to using a block fields { ... }
with the ,remain
tag and the following go struct:
type DataFields struct {
Values map[string]cty.Value `hcl:",remain"`
}
And now we can do:
fields {
my_bool = true
my_string = "string"
}
However this fails inside the dynamic
block because the body.JustAttributes()
method does not respect the scope/iteration inside a dynamic
block. This small PR addresses this and would be great if you accept this PR.