Skip to content

Commit

Permalink
Enable reference collection for count and for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Nov 30, 2022
1 parent 0397e11 commit 22775e5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions decoder/reference_origins.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,21 @@ func (d *PathDecoder) referenceOriginsInBody(body hcl.Body, bodySchema *schema.B
content := decodeBody(body, bodySchema)

for _, attr := range content.Attributes {
aSchema, ok := bodySchema.Attributes[attr.Name]
if !ok {
if bodySchema.AnyAttribute == nil {
// skip unknown attribute
continue
var aSchema *schema.AttributeSchema
if bodySchema.Extensions != nil && bodySchema.Extensions.Count && attr.Name == "count" {
aSchema = countAttributeSchema()
} else if bodySchema.Extensions != nil && bodySchema.Extensions.ForEach && attr.Name == "for_each" {
aSchema = forEachAttributeSchema()
} else {
var ok bool
aSchema, ok = bodySchema.Attributes[attr.Name]
if !ok {
if bodySchema.AnyAttribute == nil {
// skip unknown attribute
continue
}
aSchema = bodySchema.AnyAttribute
}
aSchema = bodySchema.AnyAttribute
}

if aSchema.OriginForTarget != nil {
Expand Down

0 comments on commit 22775e5

Please sign in to comment.