MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / AddMap

Function AddMap

internal/node/node.go:265–279  ·  view source on GitHub ↗

AddMap adds a new map to the parent node If it already exists, returns the existing map If it doesn't exist, returns the new map

(parent *yaml.Node, name string)

Source from the content-addressed store, hash-verified

263// If it already exists, returns the existing map
264// If it doesn't exist, returns the new map
265func AddMap(parent *yaml.Node, name string) *yaml.Node {
266 for i := 0; i < len(parent.Content); i++ {
267 if i%2 != 0 {
268 continue
269 }
270 if parent.Content[i].Value == name {
271 return parent.Content[i+1]
272 }
273 }
274 parent.Content = append(parent.Content,
275 &yaml.Node{Kind: yaml.ScalarNode, Value: name})
276 m := &yaml.Node{Kind: yaml.MappingNode, Content: make([]*yaml.Node, 0)}
277 parent.Content = append(parent.Content, m)
278 return m
279}
280
281// YamlVal converts node.Value to a string, int, or bool based on the Tag
282func YamlVal(n *yaml.Node) (any, error) {

Callers 7

AddMapSectionMethod · 0.92
processModulesSectionFunction · 0.92
TemplateFunction · 0.92
updateFunction · 0.92
writeStateFunction · 0.92
rm.goFile · 0.92
TestAddMapFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestAddMapFunction · 0.74