-
-
Notifications
You must be signed in to change notification settings - Fork 725
Open
Labels
Description
Add an "evalsubst" operator similar to "envsubst", to evaluate values as yq expressions.
It would be nice to have the ability to handle plain expressions or strings with interpolated expressions, and results which can be a string or an object. Examples are below.
yq '(.. | select(tag == "!!str")) |= evalsubst' t.yaml
Example 1:
vars:
x: 1
y: 2
z: \(.vars | .x + .y)
vars:
x: 1
y: 2
z: 3
Example 2:
vars:
x: 1
y: 2
z: The answer is \(.vars | .x + .y)
vars:
x: 1
y: 2
z: The answer is 3
Example 3:
vars:
x: 1
y: 2
z: \(.vars)
vars:
x: 1
y: 2
z:
x: 1
y: 2