Skip to content

Sub prefixes duplication. #337

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

Open
BratSinot opened this issue May 11, 2022 · 3 comments
Open

Sub prefixes duplication. #337

BratSinot opened this issue May 11, 2022 · 3 comments

Comments

@BratSinot
Copy link
Contributor

Greetings!

Any way to use prefix which contains different sub prefix without duplication?
What I mean:

use config::{Config, Environment};

fn main() {
    std::env::set_var("FOO_BAR_FIRST", "1");
    std::env::set_var("FOO_SECOND", "2");

    let conf = Config::builder()
        .add_source(Environment::with_prefix("FOO_BAR").separator("_"))
        .add_source(Environment::with_prefix("FOO").separator("_"))
        .build()
        .unwrap();

    println!("{}", conf.cache);
}

Got: { first => 1, bar => { first => 1, }, second => 2, }.
Expected: { first => 1, second => 2, }.

@matthiasbeyer
Copy link
Member

Hi! Sorry for not getting back to this earlier.

I do not see how this could currently be done, sorry. How much of an issue is this for you?

@BratSinot
Copy link
Contributor Author

BratSinot commented Jun 29, 2022

I do not see how this could currently be done, sorry. How much of an issue is this for you?

Hi,
Not really :) I just start to use one prefix FOO and get data like foo.bar.

@matthiasbeyer
Copy link
Member

Okay. I'll close this then, if that's okay with you. I hope the next generation of the config crate (see #321) does not suffer from such issues 😆

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