feat: add data interpolator

Pavel Kuzmenko requested to merge kpn/interpolator into master

Values in a dict can be set by variables and interpolated at runtime. Use a Bash-like syntax ${VARIABLE} Both $VARIABLE and ${VARIABLE} syntax is supported.

Default values can be defined inline using typical shell syntax:

  • ${VARIABLE:-default_value} evaluates to default_value if VARIABLE is unset or empty in the environment.
  • ${VARIABLE-default_value} evaluates to default_value only if VARIABLE is unset in the environment.

Similarly, the following syntax allows you to specify mandatory variables:

  • ${VARIABLE:?error_text} exits with an error message containing error_text if VARIABLE is unset or empty in the environment.
  • ${VARIABLE?error_text} exits with an error message containing error_text only if VARIABLE is unset in the environment.

Interpolation can also be nested:

  • ${VARIABLE:-${FOO}}
  • ${VARIABLE?$FOO}
  • ${VARIABLE:-${FOO:-default}}

You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign. This also prevents interpolating a value, so a $$ allows you to set name to environment variables that you don't want processed.

mirror-clients#10 (closed)

Edited by Pavel Kuzmenko

Merge request reports