From b749973fe0fbce6979b060ad87d5245bc9d1e356 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 13 Jan 2021 10:00:51 +1100 Subject: [PATCH] UnwrapDoc now private --- pkg/yqlib/operator_add.go | 4 ++-- pkg/yqlib/operator_alternative.go | 4 ++-- pkg/yqlib/operator_assign.go | 2 +- pkg/yqlib/operator_booleans.go | 6 +++--- pkg/yqlib/operator_collect.go | 2 +- pkg/yqlib/operator_create_map.go | 4 ++-- pkg/yqlib/operator_delete.go | 6 +++--- pkg/yqlib/operator_env.go | 2 +- pkg/yqlib/operator_equals.go | 4 ++-- pkg/yqlib/operator_has.go | 2 +- pkg/yqlib/operator_length.go | 2 +- pkg/yqlib/operator_multiply.go | 4 ++-- pkg/yqlib/operator_recursive_descent.go | 2 +- pkg/yqlib/operator_sort_keys.go | 2 +- pkg/yqlib/operator_tag.go | 4 ++-- pkg/yqlib/operator_traverse_path.go | 2 +- pkg/yqlib/operators.go | 2 +- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/yqlib/operator_add.go b/pkg/yqlib/operator_add.go index 7e77a99e..674b9962 100644 --- a/pkg/yqlib/operator_add.go +++ b/pkg/yqlib/operator_add.go @@ -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 diff --git a/pkg/yqlib/operator_alternative.go b/pkg/yqlib/operator_alternative.go index 3efedbc2..a099f324 100644 --- a/pkg/yqlib/operator_alternative.go +++ b/pkg/yqlib/operator_alternative.go @@ -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) diff --git a/pkg/yqlib/operator_assign.go b/pkg/yqlib/operator_assign.go index 49380daf..a4078911 100644 --- a/pkg/yqlib/operator_assign.go +++ b/pkg/yqlib/operator_assign.go @@ -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) } } diff --git a/pkg/yqlib/operator_booleans.go b/pkg/yqlib/operator_booleans.go index 8adcd795..a6e1f135 100644 --- a/pkg/yqlib/operator_booleans.go +++ b/pkg/yqlib/operator_booleans.go @@ -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 { diff --git a/pkg/yqlib/operator_collect.go b/pkg/yqlib/operator_collect.go index 46ea70b5..50a7fac4 100644 --- a/pkg/yqlib/operator_collect.go +++ b/pkg/yqlib/operator_collect.go @@ -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) diff --git a/pkg/yqlib/operator_create_map.go b/pkg/yqlib/operator_create_map.go index ed243222..d3fb21d4 100644 --- a/pkg/yqlib/operator_create_map.go +++ b/pkg/yqlib/operator_create_map.go @@ -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 diff --git a/pkg/yqlib/operator_delete.go b/pkg/yqlib/operator_delete.go index dd1613aa..729a4a8e 100644 --- a/pkg/yqlib/operator_delete.go +++ b/pkg/yqlib/operator_delete.go @@ -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) diff --git a/pkg/yqlib/operator_env.go b/pkg/yqlib/operator_env.go index 6aaef263..ba05e4d9 100644 --- a/pkg/yqlib/operator_env.go +++ b/pkg/yqlib/operator_env.go @@ -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) diff --git a/pkg/yqlib/operator_equals.go b/pkg/yqlib/operator_equals.go index accfee4a..4912e7da 100644 --- a/pkg/yqlib/operator_equals.go +++ b/pkg/yqlib/operator_equals.go @@ -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") diff --git a/pkg/yqlib/operator_has.go b/pkg/yqlib/operator_has.go index 73e85010..5cc3f2da 100644 --- a/pkg/yqlib/operator_has.go +++ b/pkg/yqlib/operator_has.go @@ -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: diff --git a/pkg/yqlib/operator_length.go b/pkg/yqlib/operator_length.go index 90cbff4b..ad375f58 100644 --- a/pkg/yqlib/operator_length.go +++ b/pkg/yqlib/operator_length.go @@ -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: diff --git a/pkg/yqlib/operator_multiply.go b/pkg/yqlib/operator_multiply.go index 0925a58c..f590d1b0 100644 --- a/pkg/yqlib/operator_multiply.go +++ b/pkg/yqlib/operator_multiply.go @@ -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) diff --git a/pkg/yqlib/operator_recursive_descent.go b/pkg/yqlib/operator_recursive_descent.go index a30bf08e..0d1a2fb9 100644 --- a/pkg/yqlib/operator_recursive_descent.go +++ b/pkg/yqlib/operator_recursive_descent.go @@ -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) diff --git a/pkg/yqlib/operator_sort_keys.go b/pkg/yqlib/operator_sort_keys.go index ba508b74..5cf61fae 100644 --- a/pkg/yqlib/operator_sort_keys.go +++ b/pkg/yqlib/operator_sort_keys.go @@ -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) } diff --git a/pkg/yqlib/operator_tag.go b/pkg/yqlib/operator_tag.go index c7449bcb..e6d71a11 100644 --- a/pkg/yqlib/operator_tag.go +++ b/pkg/yqlib/operator_tag.go @@ -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) } diff --git a/pkg/yqlib/operator_traverse_path.go b/pkg/yqlib/operator_traverse_path.go index bd1dea0d..4d9f5cf2 100644 --- a/pkg/yqlib/operator_traverse_path.go +++ b/pkg/yqlib/operator_traverse_path.go @@ -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 diff --git a/pkg/yqlib/operators.go b/pkg/yqlib/operators.go index c8eb790b..f72e32d0 100644 --- a/pkg/yqlib/operators.go +++ b/pkg/yqlib/operators.go @@ -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] }