mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Fixed deep read at root level
This commit is contained in:
@@ -12,12 +12,6 @@ func DeleteNavigationStrategy(pathElementToDelete interface{}) NavigationStrateg
|
||||
followAlias: func(nodeContext NodeContext) bool {
|
||||
return false
|
||||
},
|
||||
autoCreateMap: func(nodeContext NodeContext) bool {
|
||||
return false
|
||||
},
|
||||
shouldDeeplyTraverse: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
shouldOnlyDeeplyVisitLeaves: func(nodeContext NodeContext) bool {
|
||||
return false
|
||||
},
|
||||
|
||||
@@ -4,12 +4,6 @@ func FilterMatchingNodesNavigationStrategy(value string) NavigationStrategy {
|
||||
return &NavigationStrategyImpl{
|
||||
visitedNodes: []*NodeContext{},
|
||||
pathParser: NewPathParser(),
|
||||
followAlias: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
autoCreateMap: func(nodeContext NodeContext) bool {
|
||||
return false
|
||||
},
|
||||
visit: func(nodeContext NodeContext) error {
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -62,19 +62,32 @@ func (ns *NavigationStrategyImpl) GetVisitedNodes() []*NodeContext {
|
||||
}
|
||||
|
||||
func (ns *NavigationStrategyImpl) FollowAlias(nodeContext NodeContext) bool {
|
||||
return ns.followAlias(nodeContext)
|
||||
if ns.followAlias != nil {
|
||||
return ns.followAlias(nodeContext)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (ns *NavigationStrategyImpl) AutoCreateMap(nodeContext NodeContext) bool {
|
||||
return ns.autoCreateMap(nodeContext)
|
||||
if ns.autoCreateMap != nil {
|
||||
return ns.autoCreateMap(nodeContext)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (ns *NavigationStrategyImpl) ShouldDeeplyTraverse(nodeContext NodeContext) bool {
|
||||
return ns.shouldDeeplyTraverse(nodeContext)
|
||||
if ns.shouldDeeplyTraverse != nil {
|
||||
return ns.shouldDeeplyTraverse(nodeContext)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (ns *NavigationStrategyImpl) ShouldOnlyDeeplyVisitLeaves(nodeContext NodeContext) bool {
|
||||
return ns.shouldOnlyDeeplyVisitLeaves(nodeContext)
|
||||
if ns.shouldOnlyDeeplyVisitLeaves != nil {
|
||||
return ns.shouldOnlyDeeplyVisitLeaves(nodeContext)
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func (ns *NavigationStrategyImpl) ShouldTraverse(nodeContext NodeContext, nodeKey string) bool {
|
||||
|
||||
@@ -4,12 +4,6 @@ func ReadNavigationStrategy(deeplyTraverseArrays bool) NavigationStrategy {
|
||||
return &NavigationStrategyImpl{
|
||||
visitedNodes: []*NodeContext{},
|
||||
pathParser: NewPathParser(),
|
||||
followAlias: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
autoCreateMap: func(nodeContext NodeContext) bool {
|
||||
return false
|
||||
},
|
||||
visit: func(nodeContext NodeContext) error {
|
||||
return nil
|
||||
},
|
||||
@@ -26,8 +20,5 @@ func ReadNavigationStrategy(deeplyTraverseArrays bool) NavigationStrategy {
|
||||
}
|
||||
return deeplyTraverseArrays || !isInArray
|
||||
},
|
||||
shouldOnlyDeeplyVisitLeaves: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,6 @@ func UpdateNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) Navi
|
||||
autoCreateMap: func(nodeContext NodeContext) bool {
|
||||
return autoCreate
|
||||
},
|
||||
shouldDeeplyTraverse: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
shouldOnlyDeeplyVisitLeaves: func(nodeContext NodeContext) bool {
|
||||
return true
|
||||
},
|
||||
visit: func(nodeContext NodeContext) error {
|
||||
node := nodeContext.Node
|
||||
changesToApply := updateCommand.Value
|
||||
|
||||
Reference in New Issue
Block a user