in types/azurerm_resource.go [251:279]
func sortAttributes(input *hclwrite.Block) *hclwrite.Block {
output := hclwrite.NewBlock(input.Type(), input.Labels())
attrList := []string{"count", "for_each", "type", "parent_id", "name", "location", "identity", "body", "tags"}
usedAttr := make(map[string]bool)
for _, attr := range attrList {
if attribute := input.Body().GetAttribute(attr); attribute != nil {
output.Body().SetAttributeRaw(attr, attribute.Expr().BuildTokens(nil))
usedAttr[attr] = true
} else {
for _, block := range input.Body().Blocks() {
if block.Type() == attr {
output.Body().AppendBlock(block)
usedAttr[attr] = true
}
}
}
}
for attrName, attribute := range input.Body().Attributes() {
if _, ok := usedAttr[attrName]; !ok {
output.Body().SetAttributeRaw(attrName, attribute.Expr().BuildTokens(nil))
}
}
for _, block := range input.Body().Blocks() {
if _, ok := usedAttr[block.Type()]; !ok {
output.Body().AppendBlock(block)
}
}
return output
}