Nicer error message when trying to use merge anchor tags other than maps #1184

This commit is contained in:
Mike Farah
2022-04-27 14:46:52 +10:00
parent 70ad7a35a8
commit 26529fae94
2 changed files with 18 additions and 0 deletions
+3
View File
@@ -309,6 +309,9 @@ func doTraverseMap(newMatches *orderedmap.OrderedMap, candidate *CandidateNode,
func traverseMergeAnchor(newMatches *orderedmap.OrderedMap, originalCandidate *CandidateNode, value *yaml.Node, wantedKey string, prefs traversePreferences, splat bool) error {
switch value.Kind {
case yaml.AliasNode:
if value.Alias.Kind != yaml.MappingNode {
return fmt.Errorf("can only use merge anchors with maps (!!map), but got %v", value.Alias.Tag)
}
candidateNode := originalCandidate.CreateReplacement(value.Alias)
return doTraverseMap(newMatches, candidateNode, wantedKey, prefs, splat)
case yaml.SequenceNode: