-
Notifications
You must be signed in to change notification settings - Fork 79
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
Implement idiomatic environment variable handling #414
base: master
Are you sure you want to change the base?
Conversation
fafb6a4
to
45e0f94
Compare
5448e02
to
7bcd7ab
Compare
f0f6b50
to
29ff9c4
Compare
29ff9c4
to
e5b0a86
Compare
e5b0a86
to
c942eb0
Compare
c942eb0
to
95f4988
Compare
@sksamuel Any update on this? |
Happy for this to be breaking now, and we'll cut 3.0 |
@sksamuel Ok, then here is what I propose (this is what would be in the updated README)... please review and let me know if you are ok with this, and if you are I will make the appropriate changes. EnvironmentVariablesPropertySourceThe Hoplite maps env vars as follows:
If the optional (not specified by default) As of Hoplite 3, the |
Single underscores as path separators, uppercase. Always loaded by default in place of the override source. The override source is now unnecessary and removed. Improved path normalization disambiguation, both for classes with case-ambiguous properties and maps.
95f4988
to
d572317
Compare
@sksamuel I've rebased this branch on the latest Most of the changes to unrelated tests were because the defaults have changed, and now include the default environment. I've also added support for Spring-like env var to array/list configuration, which should resolve #402. |
@sksamuel bump |
Looks good, I guess if you want to use a prefix, you have to remove all the default sources, and add them all back in, but with a custom EnvironmentVariablesPropertySource. |
@sksamuel My thinking was that if people want to customize property sources, including the There is also the
We could potentially make the pattern simpler with some more public funs on
That is an option as well. I do think with the popularity of 12-factor apps, env vars are now very commonly used for config overrides (and rightly so), so I would hesitate to remove it from the defaults. |
Leverage the capability exposed by #413 to implement idiomatic environment variable handling.
Fixes #410.
I've tried to implement this in a backward compatible way, but if we are ok with breaking compatibility for 3.0, given the new path normalization capability, we could replace the existing logic for env vars and simplify it down to always apply env vars with the new logic, removing the
EnvironmentVariableOverridePropertySource
and simplifyingEnvironmentVariablesPropertySource
to remove all the config vals, which is what I understood from #413 (comment).This PR is stacked on top of #413 and will be rebased and moved out of draft once that PR is merged.There is a test failure in this PR which will be resolved once #444 is merged.