mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
33 lines
602 B
Go
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
|
|
}
|