MCPcopy
hub / github.com/hashicorp/hcl / RemoveAttribute

Method RemoveAttribute

hclwrite/ast_body.go:221–229  ·  view source on GitHub ↗

RemoveAttribute removes the attribute with the given name from the body. The return value is the attribute that was removed, or nil if there was no such attribute (in which case the call was a no-op).

(name string)

Source from the content-addressed store, hash-verified

219// The return value is the attribute that was removed, or nil if there was
220// no such attribute (in which case the call was a no-op).
221func (b *Body) RemoveAttribute(name string) *Attribute {
222 node := b.getAttributeNode(name)
223 if node == nil {
224 return nil
225 }
226 node.Detach()
227 b.items.Remove(node)
228 return node.content.(*Attribute)
229}
230
231// AppendBlock appends an existing block (which must not be already attached
232// to a body) to the end of the receiving body.

Callers 1

TestBodyRemoveAttributeFunction · 0.80

Implementers 8

Bodyhclsyntax/structure.go
unknownBodyext/dynblock/unknown_body.go
expandBodyext/dynblock/expand_body.go
deepWrapperext/transform/transform.go
diagBodyext/transform/error.go
bodyjson/structure.go
mockBodyhcltest/mock.go

Calls 3

getAttributeNodeMethod · 0.95
DetachMethod · 0.80
RemoveMethod · 0.80

Tested by 1

TestBodyRemoveAttributeFunction · 0.64