config icon indicating copy to clipboard operation
config copied to clipboard

How to customize the CONFIG_FORCE_ prefix

Open crash-g opened this issue 4 years ago • 6 comments
trafficstars

The documentation says that by setting the JVM property config.override_with_env_vars to true it is possible to use environment variables to override configuration values, but these variables must be prefixed with CONFIG_FORCE_.

However, in our use case we would rather not need to add a prefix, or alternatively we would like to customize it. Is it possible? Thanks!

crash-g avatar Dec 03 '20 16:12 crash-g

you can put ${SOME_ENV_VAR_NAME} in your application.conf if you want to just have certain fields that are set via env var, that's the typical use.

If you want to be able to override ANY env var, currently it requires CONFIG_FORCE prefix (because without the prefix, the env vars are used, but only as fallback not as override)

havocp avatar Dec 03 '20 17:12 havocp

Actually, we would like the following:

  • being able to override any variable without modifying the properties file
  • optionally disabling or customizing the prefix for environment variables

I am aware of the possibility to override specific variables as you describe, we are going to use it as a fallback if there is no way to do what stated above.

crash-g avatar Dec 03 '20 17:12 crash-g

there isn't a current feature for those things

havocp avatar Dec 03 '20 17:12 havocp

Thanks. Just to know: would you accept a PR that lets users configure the prefix using a JVM property?

(I have not looked at the code so I don't know how hard it is to implement)

crash-g avatar Dec 03 '20 17:12 crash-g

It seems reasonable to me I guess, open to other people's takes

havocp avatar Dec 03 '20 17:12 havocp

Alright, I'll try to have a go at it as soon as I've got time.

By the way, this is a very nice library, very ergonomic to use. Thanks!

crash-g avatar Dec 03 '20 17:12 crash-g