yq
yq copied to clipboard
Unable to use key as shell env variable
Describe the bug Cannot use key from array as value for env() function
Version of yq: v4.44.3 Operating system: mac Installed via: homebrew
Input Yaml
configmap:
values:
FOO: ""
BAR: ""
Command
$ FOO=bar yq 'with(.configmap.values[]; . = env(.))' test.yaml
Actual behavior
Error: value for env variable '.' not provided in env()
Expected behavior
configmap:
values:
FOO: bar
BAR: ""
Additional context I tried to use various combinations, but cannot find correct one. Here's example:
$ FOO=bar yq 'with(.configmap.values[]; . = env(FOO))' test.yaml
configmap:
values:
FOO: "bar"
BAR: "bar"
$ FOO=bar yq 'with(.configmap.values[]; . = env(.))' test.yaml
Error: value for env variable '.' not provided in env()
$ FOO=bar yq 'with(.configmap.values[]; . = key + "test")' test.yaml
configmap:
values:
FOO: "FOOtest"
BAR: "BARtest"
$ FOO=bar BAR=baz yq 'with(.configmap.values[]; . = env(key))' test.yaml
Error: value for env variable 'key' not provided in env()