UnwrapDoc now private

This commit is contained in:
Mike Farah 2021-01-13 10:00:51 +11:00
parent ba223df4ac
commit b749973fe0
17 changed files with 27 additions and 27 deletions

View File

@ -44,8 +44,8 @@ func addOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *PathT
}
func add(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
lhs.Node = UnwrapDoc(lhs.Node)
rhs.Node = UnwrapDoc(rhs.Node)
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
target := lhs.CreateChild(nil, &yaml.Node{})
lhsNode := lhs.Node

View File

@ -13,8 +13,8 @@ func alternativeOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNod
}
func alternativeFunc(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
lhs.Node = UnwrapDoc(lhs.Node)
rhs.Node = UnwrapDoc(rhs.Node)
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
log.Debugf("Alternative LHS: %v", lhs.Node.Tag)
log.Debugf("- RHS: %v", rhs.Node.Tag)

View File

@ -28,7 +28,7 @@ func assignUpdateOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNo
if first != nil {
rhsCandidate := first.Value.(*CandidateNode)
rhsCandidate.Node = UnwrapDoc(rhsCandidate.Node)
rhsCandidate.Node = unwrapDoc(rhsCandidate.Node)
candidate.UpdateFrom(rhsCandidate)
}
}

View File

@ -7,7 +7,7 @@ import (
)
func isTruthy(c *CandidateNode) (bool, error) {
node := UnwrapDoc(c.Node)
node := unwrapDoc(c.Node)
value := true
if node.Tag == "!!null" {
@ -27,8 +27,8 @@ type boolOp func(bool, bool) bool
func performBoolOp(op boolOp) func(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
return func(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
lhs.Node = UnwrapDoc(lhs.Node)
rhs.Node = UnwrapDoc(rhs.Node)
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
lhsTrue, errDecoding := isTruthy(lhs)
if errDecoding != nil {

View File

@ -31,7 +31,7 @@ func collectOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTr
for el := matchMap.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
log.Debugf("Collecting %v", NodeToString(candidate))
node.Content = append(node.Content, UnwrapDoc(candidate.Node))
node.Content = append(node.Content, unwrapDoc(candidate.Node))
}
results.PushBack(collectC)

View File

@ -57,8 +57,8 @@ func sequenceFor(d *dataTreeNavigator, matchingNode *CandidateNode, pathNode *Pa
log.Debugf("LHS:", NodeToString(lhs))
log.Debugf("RHS:", NodeToString(rhs))
node.Content = []*yaml.Node{
UnwrapDoc(lhs.Node),
UnwrapDoc(rhs.Node),
unwrapDoc(lhs.Node),
unwrapDoc(rhs.Node),
}
return &CandidateNode{Node: &node, Document: document, Path: path}, nil

View File

@ -49,7 +49,7 @@ func deleteImmediateChildOperator(d *dataTreeNavigator, matchingNodes *list.List
for el := parents.Front(); el != nil; el = el.Next() {
parent := el.Value.(*CandidateNode)
parentNode := UnwrapDoc(parent.Node)
parentNode := unwrapDoc(parent.Node)
if parentNode.Kind == yaml.MappingNode {
deleteFromMap(parent, childPath)
} else if parentNode.Kind == yaml.SequenceNode {
@ -64,7 +64,7 @@ func deleteImmediateChildOperator(d *dataTreeNavigator, matchingNodes *list.List
func deleteFromMap(candidate *CandidateNode, childPath interface{}) {
log.Debug("deleteFromMap")
node := UnwrapDoc(candidate.Node)
node := unwrapDoc(candidate.Node)
contents := node.Content
newContents := make([]*yaml.Node, 0)
@ -87,7 +87,7 @@ func deleteFromMap(candidate *CandidateNode, childPath interface{}) {
func deleteFromArray(candidate *CandidateNode, childPath interface{}) {
log.Debug("deleteFromArray")
node := UnwrapDoc(candidate.Node)
node := unwrapDoc(candidate.Node)
contents := node.Content
newContents := make([]*yaml.Node, 0)

View File

@ -38,7 +38,7 @@ func envOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTreeNo
return nil, errorReading
}
//first node is a doc
node = UnwrapDoc(&dataBucket)
node = unwrapDoc(&dataBucket)
}
log.Debug("ENV tag", node.Tag)
log.Debug("ENV value", node.Value)

View File

@ -12,8 +12,8 @@ func equalsOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *Pa
func isEquals(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
value := false
lhsNode := UnwrapDoc(lhs.Node)
rhsNode := UnwrapDoc(rhs.Node)
lhsNode := unwrapDoc(lhs.Node)
rhsNode := unwrapDoc(rhs.Node)
if lhsNode.Tag == "!!null" {
value = (rhsNode.Tag == "!!null")

View File

@ -24,7 +24,7 @@ func hasOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *PathT
candidate := el.Value.(*CandidateNode)
// grab the first value
candidateNode := UnwrapDoc(candidate.Node)
candidateNode := unwrapDoc(candidate.Node)
var contents = candidateNode.Content
switch candidateNode.Kind {
case yaml.MappingNode:

View File

@ -13,7 +13,7 @@ func lengthOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTre
for el := matchMap.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
targetNode := UnwrapDoc(candidate.Node)
targetNode := unwrapDoc(candidate.Node)
var length int
switch targetNode.Kind {
case yaml.ScalarNode:

View File

@ -54,8 +54,8 @@ func multiplyOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *
func multiply(preferences *multiplyPreferences) func(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
return func(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
lhs.Node = UnwrapDoc(lhs.Node)
rhs.Node = UnwrapDoc(rhs.Node)
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
log.Debugf("Multipling LHS: %v", lhs.Node.Tag)
log.Debugf("- RHS: %v", rhs.Node.Tag)

View File

@ -27,7 +27,7 @@ func recursiveDecent(d *dataTreeNavigator, results *list.List, matchMap *list.Li
for el := matchMap.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
candidate.Node = UnwrapDoc(candidate.Node)
candidate.Node = unwrapDoc(candidate.Node)
log.Debugf("Recursive Decent, added %v", NodeToString(candidate))
results.PushBack(candidate)

View File

@ -17,7 +17,7 @@ func sortKeysOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *
}
for childEl := rhs.Front(); childEl != nil; childEl = childEl.Next() {
node := UnwrapDoc(childEl.Value.(*CandidateNode).Node)
node := unwrapDoc(childEl.Value.(*CandidateNode).Node)
if node.Kind == yaml.MappingNode {
sortKeys(node)
}

View File

@ -41,7 +41,7 @@ func assignTagOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode
tag = rhs.Front().Value.(*CandidateNode).Node.Value
}
}
UnwrapDoc(candidate.Node).Tag = tag
unwrapDoc(candidate.Node).Tag = tag
}
return matchingNodes, nil
@ -54,7 +54,7 @@ func getTagOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *Pa
for el := matchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
node := &yaml.Node{Kind: yaml.ScalarNode, Value: UnwrapDoc(candidate.Node).Tag, Tag: "!!str"}
node := &yaml.Node{Kind: yaml.ScalarNode, Value: unwrapDoc(candidate.Node).Tag, Tag: "!!str"}
result := candidate.CreateChild(nil, node)
results.PushBack(result)
}

View File

@ -146,7 +146,7 @@ func traverseMapWithIndices(candidate *CandidateNode, indices []*yaml.Node, pref
func traverseArrayWithIndices(candidate *CandidateNode, indices []*yaml.Node) (*list.List, error) {
log.Debug("traverseArrayWithIndices")
var newMatches = list.New()
node := UnwrapDoc(candidate.Node)
node := unwrapDoc(candidate.Node)
if len(indices) == 0 {
log.Debug("splatting")
var index int64

View File

@ -9,7 +9,7 @@ import (
type operatorHandler func(d *dataTreeNavigator, matchingNodes *list.List, pathNode *PathTreeNode) (*list.List, error)
func UnwrapDoc(node *yaml.Node) *yaml.Node {
func unwrapDoc(node *yaml.Node) *yaml.Node {
if node.Kind == yaml.DocumentNode {
return node.Content[0]
}