findMapKeyIndex returns the index of key node in dst mapping (index of key, not value). Returns -1 when not found.
(mapNode *yaml.Node, key string)
| 1457 | // findMapKeyIndex returns the index of key node in dst mapping (index of key, not value). |
| 1458 | // Returns -1 when not found. |
| 1459 | func findMapKeyIndex(mapNode *yaml.Node, key string) int { |
| 1460 | if mapNode == nil || mapNode.Kind != yaml.MappingNode { |
| 1461 | return -1 |
| 1462 | } |
| 1463 | for i := 0; i+1 < len(mapNode.Content); i += 2 { |
| 1464 | if mapNode.Content[i] != nil && mapNode.Content[i].Value == key { |
| 1465 | return i |
| 1466 | } |
| 1467 | } |
| 1468 | return -1 |
| 1469 | } |
| 1470 | |
| 1471 | // appendPath appends a key to the path, returning a new slice to avoid modifying the original. |
| 1472 | func appendPath(path []string, key string) []string { |
no outgoing calls
no test coverage detected