question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a feature for auto-binding from JVM and env variables

See original GitHub issue

Rationale 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 become FOO_BAR_IS_COOL), and look up in the env vars. If present, those will override application.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:open
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nigredo-toricommented, Feb 28, 2020

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 the foo.barIsCool config value.

The implementation for the above should be relatively simple. Just take sys.env, filter/strip (configurable) key prefix as desired, pass to ConfigFactory.parseMap, and wrap the result as a ConfigSource. That ConfigSource can then be inserted into the ConfigSource 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 described ConfigSource builder as a part of the library itself, but at the very least this is now achievable.

0reactions
nigredo-toricommented, Mar 9, 2020

shells only support alphanumeric characters and underscores

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found