yq/pkg/yqlib/operator_env.go
Mike Farah 2d9cc3c107 wip
2021-02-11 10:58:40 +11:00

33 lines
602 B
Go

package yqlib
import (
"container/list"
"os"
yaml "gopkg.in/yaml.v3"
)
// type EnvOpPreferences struct {
// StringValue bool
// }
func EnvOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTreeNode) (*list.List, error) {
envName := pathNode.Operation.CandidateNode.Node.Value
log.Debug("EnvOperator, env name:", envName)
rawValue := os.Getenv(envName)
target := &CandidateNode{
Path: make([]interface{}, 0),
Document: 0,
Filename: "",
Node: &yaml.Node{
Kind: yaml.ScalarNode,
Tag: "!!str",
Value: rawValue,
},
}
return nodeToMap(target), nil
}