yq/pkg/yqlib/operator_pipe.go
Mike Farah 62d167c141
Variable loop - Fixes #1566 (#1577)
* Variable loop wip

* Variable loop wip

* Variable loop wip

* Variable loop wip

* Fixed variable operator to work like jq
2023-02-28 16:40:38 +11:00

19 lines
512 B
Go

package yqlib
func pipeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
if expressionNode.LHS.Operation.OperationType == assignVariableOpType {
return variableLoop(d, context, expressionNode)
}
lhs, err := d.GetMatchingNodes(context, expressionNode.LHS)
if err != nil {
return Context{}, err
}
rhs, err := d.GetMatchingNodes(lhs, expressionNode.RHS)
if err != nil {
return Context{}, err
}
return context.ChildContext(rhs.MatchingNodes), nil
}