Open raz-bn opened 6 months ago
Hi @raz-bn,
The "hcl" struct tags only interact with HCL blocks and their direct attributes. From HCL's perspective that versioning
argument is just a single expression evaluated all at once, so HCL does not destructure it.
gohcl
handles each attribute by passing it to gohcl.DecodeExpression
, which in turn delegates to a third-party package gocty
to convert to the final type. Therefore you would need to use that package's struct tags for your type Versioning
:
type Versioning struct {
Enabled bool `cty:"enabled"`
}
Hey, I am trying to parse terraform HCL into Golang struct and im facing issues when trying to parse an object inside a Module block. this it the example I am trying to make work: Terraform file:
Golang struct:
I am being able to parse both of
source
andbucket
attributes, however, no matter what I try I was not able to parse theversioning
attribute.