Manage multiple environment variable setups.
A lot of tools take their configuraetion from environment variables. For certain configurations several environment variables have to be set simulateneously and switching between configurations becomes cumbersome or one has to create wrapper scripts etc. This is where runctl
comes to help.
create file test.yaml
:
myenv:
- name: FOO
value: foo
action: new
- name: BAR
value: bar
action: new
otherenv:
- name: BAR
value: barother
action: replace
- name: BAZ
value: baz
action: merge
separator: ":"
runctl -config-file test.yaml -config myenv -- 'echo $BAR'
output is:
bar
then run the same command using different environment configuration (otherenv
)
runctl -config-file test.yaml -config otherenv -- 'echo $BAR'
output is:
barother
And of course one can use environment variables runctl_CONFIG
and runctl_ENV
to streamline use of runctl
even further and have it as inobtrusive as possible:
export RUNCTL_CONFIG=test.yaml
export RUNCTL_ENV=myenv
runctl echo '$BAR'
only set variable if it hasn't been already set
default behavior: replace existing variable value
treat variable as array splitting using separator
, append value to existing array
unset existing value - as if it was never set to begin with