mehcode / config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Apache License 2.0
2.57k stars 213 forks source link

Sub prefixes duplication. #337

Open BratSinot opened 2 years ago

BratSinot commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 :laughing: