Added eval operator

This commit is contained in:
Mike Farah
2022-02-01 14:47:51 +11:00
parent 77204551ab
commit 535799462f
19 changed files with 209 additions and 30 deletions
+10
View File
@@ -53,6 +53,16 @@ var envOperatorScenarios = []expressionScenario{
"D0, P[], ()::a: \"12\"\n",
},
},
{
description: "Dynamically evaluate a path from an environment variable",
subdescription: "The env variable can be any valid yq expression.",
document: `{a: {b: [{name: dog}, {name: cat}]}}`,
environmentVariable: ".a.b[0].name",
expression: `eval(strenv(myenv))`,
expected: []string{
"D0, P[a b 0 name], (!!str)::dog\n",
},
},
{
description: "Dynamic key lookup with environment variable",
environmentVariable: "cat",