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

Function SetMapValue

internal/node/node.go:229–242  ·  view source on GitHub ↗

Add or replace a map value

(parent *yaml.Node, name string, val *yaml.Node)

Source from the content-addressed store, hash-verified

227
228// Add or replace a map value
229func SetMapValue(parent *yaml.Node, name string, val *yaml.Node) {
230 found := false
231 for i, v := range parent.Content {
232 if v.Kind == yaml.ScalarNode && v.Value == name {
233 found = true
234 parent.Content[i+1] = val
235 break
236 }
237 }
238 if !found {
239 parent.Content = append(parent.Content, &yaml.Node{Kind: yaml.ScalarNode, Value: name})
240 parent.Content = append(parent.Content, val)
241 }
242}
243
244// Set the value of a sequence element within the node
245func SetSequenceValue(parent *yaml.Node, val *yaml.Node, sidx int) {

Callers 3

includeS3ObjectFunction · 0.92
runDriftOnStateFunction · 0.92
TestSetMapValueFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestSetMapValueFunction · 0.74