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

Allow Value::find to traverse arrays #92

Open
thorio opened this issue Feb 6, 2024 · 1 comment
Open

Allow Value::find to traverse arrays #92

thorio opened this issue Feb 6, 2024 · 1 comment

Comments

@thorio
Copy link
Contributor

thorio commented Feb 6, 2024

Use Case

Given a configuration file like this:

providers:
  - plugin: calculator
    config:
      some_stuff: ""
  - plugin: websearch
    config:
      some_other_stuff: ""

I'd like to be able to focus on providers.1.config, merge/join other providers and then deserialize the contents into an arbitrary struct defined by the websearch plugin.

Petition

Currently, Value::find and, by proxy, Figment::focus work exclusively on dict keys, arrays are ignored.
If we extend Value::find and Value::find_ref to attempt to index arrays, arrays can be traversed and the contained dicts found/focused on.

I managed to hack support into it on my fork and it works perfectly for my use case.

Is this feature wanted in this project? If so, I'd be happy to update find_ref, docs, tests and submit a PR.

@luizfonseca
Copy link

+1, This would be a nice addition (currently I can't "override" specific configs env-wise)

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