rust-cli / rust-cli/config-rs

Enh Req: Introduce Config metadata for troubleshoot of override/layered values

Open
#407 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.2k
Forks
265
Avg merge
2h 42m
Merged PRs (30d)
4

Description

Hi, in many situations when multiple sources of configurations are used - it's beneficial to have ability of Config metadata to tell which value came from which source and became effective/actual at the end of sources processing.

Implementation of this could add extra feature, for example "config-meta" and once used/enabled - later have method like "get_meta" or "dump_meta".

So if let say I have something like such for config construction out of 2 sources:

fn make_config() -> Config {
  let current_env = env::var("ENV").unwrap();
  Config::builder()
      .add_source(File::new("env/service", FileFormat::Yaml))
      .add_source(File::new(("env/service-".to_string() + &current_env).as_str(), FileFormat::Yaml))
      .build()
      .unwrap()
}

and let say one of my YAMLs has such:

debug: false

and another:

debug: true

then that new method "dump_meta" could print something like this:

debug: false <= taken from service.yml
debug: true <= taken as override from service-dev.yml and effective

As I'm yet new to Rust - this is just proposal at this point from my side, which I could try to implement one day if no volunteers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Config::builder and the add_source processing flow described in the issue. Determine how layered values could retain their source information, then define and document a config-meta capability such as get_meta or dump_meta that reports each value's source and which value is effective after overrides.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.