Skip to content

Commit

Permalink
Only check block length if there is no dependent body
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Nov 29, 2022
1 parent 59b41cf commit ed6bd92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func mergeBlockBodySchemas(block *hcl.Block, blockSchema *schema.BlockSchema) (*
mergedSchema.ImpliedOrigins = make([]schema.ImpliedOrigin, 0)
}

if mergedSchema.Extensions != nil && mergedSchema.Extensions.DynamicBlocks && len(mergedSchema.Blocks) > 0 {
mergedSchema.Blocks["dynamic"] = buildDynamicBlockSchema(mergedSchema)
}

depSchema, _, ok := NewBlockSchema(blockSchema).DependentBodySchema(block)
if ok {
for name, attr := range depSchema.Attributes {
Expand Down Expand Up @@ -97,6 +93,10 @@ func mergeBlockBodySchemas(block *hcl.Block, blockSchema *schema.BlockSchema) (*
if depSchema.Extensions != nil {
mergedSchema.Extensions = depSchema.Extensions.Copy()
}
} else {
if mergedSchema.Extensions != nil && mergedSchema.Extensions.DynamicBlocks && len(mergedSchema.Blocks) > 0 {
mergedSchema.Blocks["dynamic"] = buildDynamicBlockSchema(mergedSchema)
}
}

return mergedSchema, nil
Expand Down

0 comments on commit ed6bd92

Please sign in to comment.