yq/pkg/yqlib/operator_document_index.go

21 lines
556 B
Go
Raw Permalink Normal View History

2020-11-06 01:11:38 +00:00
package yqlib
import (
"container/list"
"fmt"
"gopkg.in/yaml.v3"
)
func getDocumentIndexOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
2020-11-06 01:11:38 +00:00
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
2020-11-06 01:11:38 +00:00
candidate := el.Value.(*CandidateNode)
node := &yaml.Node{Kind: yaml.ScalarNode, Value: fmt.Sprintf("%v", candidate.Document), Tag: "!!int"}
2021-11-23 22:57:35 +00:00
scalar := candidate.CreateReplacement(node)
2020-11-06 01:11:38 +00:00
results.PushBack(scalar)
}
return context.ChildContext(results), nil
2020-11-06 01:11:38 +00:00
}