Skip to content

Cannot provide environment variables programmatically #796

@przemek-pokrywka

Description

@przemek-pokrywka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions