maddy icon indicating copy to clipboard operation
maddy copied to clipboard

cfgparser: add env_split for splitting of ENV variable values on comma

Open rjocoleman opened this issue 1 year ago • 0 comments

This PR adds a new config placeholder syntax, {env_split:VAR_NAME}, alongside the existing {env:VAR_NAME}

  • {env:VAR_NAME}: Substitutes the value of the environment variable VAR_NAME as is, preserving its format, including any commas.
  • {env_split:VAR_NAME}: Substitutes the value of the environment variable VAR_NAME, converting any commas in the value into spaces. This is particularly useful for configurations that expect space-separated lists but are populated from environment variables that naturally format such lists as comma-separated strings.

The use case of $(local_domains) = $(primary_domain) example.com multiple domains in Docker can now use this feature by setting an environment variable with a value like domain1.com,domain2.com. Using {env_split:OTHER_DOMAINS} will automatically convert this to domain1.com domain2.com, fitting into configurations that require space-separated values.

I have also added test cases for splitting, not split and mixing both.

rjocoleman avatar Mar 16 '24 05:03 rjocoleman