Provide a feature for auto-binding from JVM and env variables
See original GitHub issueRationale Having worked with Spring Boot’s excellent configuration management, I really miss the benefits in Scala. I’d like to propose a new feature that I think will cut down the boilerplate a lot, thus making pureconfig even more awesome 😄 and reduce chances of user error.
Proposal For every property in that’s being bound -
- Convert to env var format (
foo.barIsCool
will becomeFOO_BAR_IS_COOL
), and look up in the env vars. If present, those will overrideapplication.conf
and any default in code. - Look up as-is (no conversion) in the JVM variables. If present, those will override env var,
application.conf
and any default in code.
The above can be made available as a new hint that the users can choose. Also,
- Allow comma-separated strings to be treated as
Iterable
. Overriding each elements of the list from command line is simply waste of time.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
The JAVA_TOOL_OPTIONS Environment Variable
This guide helps you to troubleshoot issues that might occur with Java Client applications created on the Java Platform, Standard Edition (Java SE)...
Read more >Autobind and Environment Variables in xMII
Have you ever wondered how to pass environment variables to xMII transactions ? You are trying to create a BLS transaction and you...
Read more >Passing environment variables to a JVM, in a platform- ...
Could I just skip passing the variable into the JVM completely, and use getenv() after using setting the value for an environment variable...
Read more >Using Environment Variables
These variables are scoped to the function and are not visible to other functions in ... To set a a runtime environment variable...
Read more >Spark profiling - env variable resolution?
We'll add a feature request to allow environment variable resolution ... variable programmatically a launcher script which starts the JVM.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for digging up this old issue, but it has come up in an internal discussion at my workplace, and I figured it wouldn’t hurt to provide a little update.
While a lot of the proposed features are difficult to implement, one cheap thing we can do is add support for injection through environment variables (albeit without mangling names). So we can have
PREFIX_foo.barIsCool
environment variable being treated as a candidate for thefoo.barIsCool
config value.The implementation for the above should be relatively simple. Just take
sys.env
, filter/strip (configurable) key prefix as desired, pass toConfigFactory.parseMap
, and wrap the result as aConfigSource
. ThatConfigSource
can then be inserted into theConfigSource
stack.I don’t think this should be a part of the default
ConfigSource
stack, and I’m not sure this pattern is even common enough to provide the describedConfigSource
builder as a part of the library itself, but at the very least this is now achievable.Sorry, I haven’t taken this into account. This means that we would still need some kind of mangling - probably something like what happens to
CONFIG_FORCE_
variables.