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

Can't overwrite settings with underscores using env varibles #73

Closed
brizental opened this issue Jun 28, 2018 · 2 comments
Closed

Can't overwrite settings with underscores using env varibles #73

brizental opened this issue Jun 28, 2018 · 2 comments

Comments

@brizental
Copy link

So, I have a default.json that I can overwrite using my custom prefixed env variables (just like https://github.com/mehcode/config-rs/blob/master/examples/hierarchical-env/src/settings.rs#L58).

I tried adding a key in that json that has underscores in it { "like_this": "blabla" }. I expected it to be overwritten by an env varible like APP_LIKE_THIS but that doesn't work.

Is this a bug or am I doing something wrong?

@brizental
Copy link
Author

Closing this because I understand now that this is a design choice.

@mehcode
Copy link
Collaborator

mehcode commented Jul 2, 2018

@brizental This behavior was changed in 0.9. Env variables match with underscores by default as you would expect. If you want nesting behavior you need to now opt-in to it.

// `APP_FOO_BAR` will match `foo_bar`
Environment::with_prefix("APP");

// `APP_FOO_BAR` will match `foo.bar` (nested struct)
// This was the default behavior in 0.8
Environment::with_prefix("APP").separator("_");

// `APP_FOO__BAR_BAZ` will match `foo.bar_baz` (nested struct)
Environment::with_prefix("APP").separator("__");

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

2 participants