in hcl_block.go [225:249]
func CloneHclSyntaxBlock(hb *hclsyntax.Block) *hclsyntax.Block {
// Clone the block itself
cloneBlock := clone(hb)
// Clone the body
cloneBody := &hclsyntax.Body{
Attributes: make(hclsyntax.Attributes),
Blocks: make(hclsyntax.Blocks, len(hb.Body.Blocks)),
}
// Clone attributes
for name, attr := range hb.Body.Attributes {
cloneBody.Attributes[name] = clone(attr)
}
// Clone blocks recursively
for i, block := range hb.Body.Blocks {
cloneBody.Blocks[i] = CloneHclSyntaxBlock(block)
}
// Assign the cloned body to the cloned block
cloneBlock.Body = cloneBody
return cloneBlock
}