mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
1.1 KiB
1.1 KiB
Read string environment variable
Running
myenv="cat meow" yq eval --null-input '.a = env(myenv)'
will output
a: cat meow
Read boolean environment variable
Running
myenv="true" yq eval --null-input '.a = env(myenv)'
will output
a: true
Read numeric environment variable
Running
myenv="12" yq eval --null-input '.a = env(myenv)'
will output
a: 12
Read yaml environment variable
Running
myenv="{b: fish}" yq eval --null-input '.a = env(myenv)'
will output
a: {b: fish}
Read boolean environment variable as a string
Running
myenv="true" yq eval --null-input '.a = strenv(myenv)'
will output
a: "true"
Read numeric environment variable as a string
Running
myenv="12" yq eval --null-input '.a = strenv(myenv)'
will output
a: "12"
Dynamic key lookup with environment variable
Given a sample.yml file of:
cat: meow
dog: woof
then
myenv="cat" yq eval '.[env(myenv)]' sample.yml
will output
meow