Add or replace a map value
(parent *yaml.Node, name string, val *yaml.Node)
| 227 | |
| 228 | // Add or replace a map value |
| 229 | func 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 |
| 245 | func SetSequenceValue(parent *yaml.Node, val *yaml.Node, sidx int) { |
no outgoing calls