Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use key as shell env variable #2177

Open
NikonNLG opened this issue Oct 17, 2024 · 0 comments
Open

Unable to use key as shell env variable #2177

NikonNLG opened this issue Oct 17, 2024 · 0 comments
Labels

Comments

@NikonNLG
Copy link

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@NikonNLG and others