mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-27 08:55:37 +00:00
Merge anchors - refactored
This commit is contained in:
parent
865a55645c
commit
784513dd18
@ -303,7 +303,7 @@ func (n *navigator) visitAliases(contents []*yaml.Node, key string, visit mapVis
|
|||||||
return visitedAlias, errorInAlias
|
return visitedAlias, errorInAlias
|
||||||
}
|
}
|
||||||
} else if contents[index+1].Kind == yaml.SequenceNode {
|
} else if contents[index+1].Kind == yaml.SequenceNode {
|
||||||
// could be an array of aliases...need to search this backwards too!
|
// could be an array of aliases...
|
||||||
visitedAliasSeq, errorVisitingAliasSeq := n.visitAliasSequence(contents[index+1].Content, key, visit)
|
visitedAliasSeq, errorVisitingAliasSeq := n.visitAliasSequence(contents[index+1].Content, key, visit)
|
||||||
if visitedAliasSeq == true || errorVisitingAliasSeq != nil {
|
if visitedAliasSeq == true || errorVisitingAliasSeq != nil {
|
||||||
return visitedAliasSeq, errorVisitingAliasSeq
|
return visitedAliasSeq, errorVisitingAliasSeq
|
||||||
@ -315,6 +315,7 @@ func (n *navigator) visitAliases(contents []*yaml.Node, key string, visit mapVis
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *navigator) visitAliasSequence(possibleAliasArray []*yaml.Node, key string, visit mapVisitorFn) (bool, error) {
|
func (n *navigator) visitAliasSequence(possibleAliasArray []*yaml.Node, key string, visit mapVisitorFn) (bool, error) {
|
||||||
|
// need to search this backwards too, so that aliases defined last override the preceding.
|
||||||
for aliasIndex := len(possibleAliasArray) - 1; aliasIndex >= 0; aliasIndex = aliasIndex - 1 {
|
for aliasIndex := len(possibleAliasArray) - 1; aliasIndex >= 0; aliasIndex = aliasIndex - 1 {
|
||||||
child := possibleAliasArray[aliasIndex]
|
child := possibleAliasArray[aliasIndex]
|
||||||
if child.Kind == yaml.AliasNode {
|
if child.Kind == yaml.AliasNode {
|
||||||
|
Loading…
Reference in New Issue
Block a user