in pkg/terraform/nested_block.go [25:57]
func (nb *NestedBlock) RemoveContent(path string) {
segs := strings.Split(path, "/")
current := segs[0]
if len(segs) > 1 {
myNbs, ok := nb.NestedBlocks[current]
if !ok {
return
}
nextPath := strings.Join(segs[1:], "/")
for _, myNb := range myNbs {
myNb.RemoveContent(nextPath)
}
return
}
_, ok := nb.Attributes[current]
if ok {
nb.WriteBody().RemoveAttribute(current)
return
}
myNbs, ok := nb.NestedBlocks[current]
if !ok {
return
}
block := nb.WriteBlock
if nb.Type == "dynamic" {
contentBlock := nb.WriteBlock.Body().Blocks()[0]
block = contentBlock
}
for _, myNb := range myNbs {
block.Body().RemoveBlock(myNb.selfWriteBlock)
}
}