yq/pkg/yqlib/update_navigation_strategy.go

34 lines
874 B
Go
Raw Normal View History

2019-12-25 01:11:04 +00:00
package yqlib
import (
yaml "gopkg.in/yaml.v3"
)
2019-12-28 07:19:37 +00:00
func UpdateNavigationStrategy(changesToApply *yaml.Node) NavigationStrategy {
return &NavigationStrategyImpl{
visitedNodes: []*NodeContext{},
followAlias: func(nodeContext NodeContext) bool {
2019-12-25 01:11:04 +00:00
return false
},
2019-12-28 07:19:37 +00:00
autoCreateMap: func(nodeContext NodeContext) bool {
2019-12-25 01:11:04 +00:00
return true
},
2019-12-28 07:19:37 +00:00
visit: func(nodeContext NodeContext) error {
node := nodeContext.Node
2019-12-25 01:11:04 +00:00
log.Debug("going to update")
DebugNode(node)
log.Debug("with")
DebugNode(changesToApply)
node.Value = changesToApply.Value
node.Tag = changesToApply.Tag
node.Kind = changesToApply.Kind
node.Style = changesToApply.Style
node.Content = changesToApply.Content
node.HeadComment = changesToApply.HeadComment
node.LineComment = changesToApply.LineComment
node.FootComment = changesToApply.FootComment
return nil
},
}
}