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

Is there a way to unset a key using environment variables? #582

Closed
grillorafael opened this issue Sep 3, 2018 · 3 comments
Closed

Is there a way to unset a key using environment variables? #582

grillorafael opened this issue Sep 3, 2018 · 3 comments

Comments

@grillorafael
Copy link

If I have a key with a default value set but I want to be able to unset in case I have a given ENV variable present. Is there a way to do it ?

@ktoso
Copy link
Contributor

ktoso commented Sep 4, 2018

Set it to an empty string?

@havocp
Copy link
Collaborator

havocp commented Sep 4, 2018

TL;DR not really.

The tricky thing about env vars is that they always contain strings, which means "VAR=null" comes through as the string "null" rather than a null value. No great solution to this... env vars only go so far. A more flexible solution in the long run can be to use env vars to specify a -Dconfig.file=$FILE kind of thing, where $FILE can be different for each distinct configuration you have, while including another file with common configuration.

There was some discussion on an issue I can't find of allowing JSON/HOCON to appear in env vars somehow... I don't remember exactly what that idea was but I think maybe it was a certain env var like CONFIG_OVERRIDES='{ "some.key" : null }' ... or it could be -Dconfig.env=MY_HOCON_VARNAME I don't know. Anyway that's a feature idea that could help with this sort of thing, many details to be worked out though.

@havocp havocp closed this as completed Sep 4, 2018
@grillorafael
Copy link
Author

Thanks for the answer @havocp and @ktoso

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

3 participants