diff --git a/pkg/yqlib/doc/Document Index.md b/pkg/yqlib/doc/Document Index.md index 024e4916..f9a2366e 100644 --- a/pkg/yqlib/doc/Document Index.md +++ b/pkg/yqlib/doc/Document Index.md @@ -1,4 +1,4 @@ -Use the `documentIndex` operator to select nodes of a particular document. +Use the `documentIndex` operator (or the `di` shorthand) to select nodes of a particular document. ## Retrieve a document index Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/operator_env.go b/pkg/yqlib/operator_env.go index 4cfeeb3c..f80a700c 100644 --- a/pkg/yqlib/operator_env.go +++ b/pkg/yqlib/operator_env.go @@ -2,6 +2,7 @@ package yqlib import ( "container/list" + "fmt" "os" "strings" @@ -27,6 +28,8 @@ func EnvOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTreeNo Tag: "!!str", Value: rawValue, } + } else if rawValue == "" { + return nil, fmt.Errorf("Value for env variable '%v' not provided in env()", envName) } else { var dataBucket yaml.Node decoder := yaml.NewDecoder(strings.NewReader(rawValue)) diff --git a/pkg/yqlib/operator_recursive_descent_test.go b/pkg/yqlib/operator_recursive_descent_test.go index 5f63d329..6f5b2900 100644 --- a/pkg/yqlib/operator_recursive_descent_test.go +++ b/pkg/yqlib/operator_recursive_descent_test.go @@ -63,10 +63,10 @@ var recursiveDescentOperatorScenarios = []expressionScenario{ }, }, { - description: "Recursively find nodes with keys", + description: "Recursively find nodes with keys", subdescription: "Note that this example has wrapped the expression in `[]` to show that there are two matches returned. You do not have to wrap in `[]` in your path expression.", - document: `{a: {name: frog, b: {name: blog, age: 12}}}`, - expression: `[.. | select(has("name"))]`, + document: `{a: {name: frog, b: {name: blog, age: 12}}}`, + expression: `[.. | select(has("name"))]`, expected: []string{ "D0, P[a], (!!seq)::- {name: frog, b: {name: blog, age: 12}}\n- {name: blog, age: 12}\n", },