This commit is contained in:
Mike Farah
2021-02-11 10:58:40 +11:00
parent 018a6e616d
commit 2d9cc3c107
2 changed files with 132 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
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
}