(root *yaml.Node, key string)
| 107 | } |
| 108 | |
| 109 | func getMapping(root *yaml.Node, key string) (*yaml.Node, error) { |
| 110 | var node *yaml.Node |
| 111 | l := len(root.Content) |
| 112 | for i := 0; i < l; i += 2 { |
| 113 | k := root.Content[i] |
| 114 | if k.Kind != yaml.ScalarNode || k.Tag != "!!str" { |
| 115 | return nil, fmt.Errorf("expected mapping key to be a string, got %v %v", root.Kind, k.Tag) |
| 116 | } |
| 117 | if k.Value == key { |
| 118 | node = root.Content[i+1] |
| 119 | return node, nil |
| 120 | } |
| 121 | } |
| 122 | return nil, fmt.Errorf("key %v not found", key) |
| 123 | } |
| 124 | |
| 125 | // replace changes yaml node value in stream at position, preserving content |
| 126 | func replace(in []byte, line int, column int, value string) []byte { |
no outgoing calls
no test coverage detected