Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot provide environment variables programmatically #796

Open
przemek-pokrywka opened this issue Aug 9, 2023 · 0 comments
Open

Cannot provide environment variables programmatically #796

przemek-pokrywka opened this issue Aug 9, 2023 · 0 comments

Comments

@przemek-pokrywka
Copy link

Many container-era applications follow the 12-factor-app specification which puts focus on environment variables. The environment variable substitutions used in the configuration files can not be easily tested, which is a problem when the configuration is complex and when one wants to run multiple parallel tests, each with different variables substituted.

Why is substituting environment variables programmatically difficult: the JVM does not expose any API for altering an environment variable unless you resort to some reflection API hacks. Also, even then, the variable gets substituted globally, which prevents you from running different similar tests in parallel.

There exist libraries that address these issues by letting the user programmatically alter the environment variables in specified scope (ZIO Config, thanks to ZIO TestSystem), but when you integrate them with this library, they fall short, because Lightbend Config only ever uses the JVM's System class directly.

Ideally, Lightbend Config would expose an API that would let one substitute environment variables programmatically, for the time of loading/resolving of configuration. Such an API could then be used directly or through testing libraries that support the notion of env. var. substitutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant