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

Handle ambiguous paths #13

Closed
bbqsrc opened this issue Mar 23, 2021 · 5 comments
Closed

Handle ambiguous paths #13

bbqsrc opened this issue Mar 23, 2021 · 5 comments

Comments

@bbqsrc
Copy link

bbqsrc commented Mar 23, 2021

Hey!

Wondering if it would be possible to add support for ambiguous paths. Let's say I want to split by _ but I also have a nested variable that happens to also include _.

struct Config {
    foo: Foo
}

struct Foo {
    a_b_c: String
}

An environment variable of FOO_A_B_C=hi doesn't resolve correctly, even though I would expect it to, with the following config:

Figment::new()
    .merge(Env::split("_"))
    .extract()

Is this something that is within scope for this project?

@SergioBenitez
Copy link
Owner

SergioBenitez commented Mar 25, 2021

I'm not entirely sure which exact functionality you'd like, but have a look at a recent similar discussion in #12 about the inherent difficulties surrounding issues like this. After reading that, could you explain, perhaps with a complete, concrete example, what you might want Figment to do?

@bbqsrc
Copy link
Author

bbqsrc commented Mar 25, 2021

I have no idea how I missed #12, given it's essentially what I am discussing here. 😄

Give me a few days, I'll have a poke and come back with a coherent example after properly reviewing the codebase and perhaps coming up with a draft PR to demonstrate my thinking (no expectation to merge, don't worry, I just find it easier to explain with functionality sometimes).

@DanielJoyce
Copy link

I used double underscores for dot, and it works great. Use the split feature to split on "__"

SOME__NESTED__ENV_VAR will them be treated like some.nested.env_var

@SergioBenitez
Copy link
Owner

@bbqsrc Is it safe to close this out?

@bbqsrc
Copy link
Author

bbqsrc commented Apr 10, 2021

My time for this ended up being consumed by GraphQL horrors, so I think so. The double underscore approach solves my immediate issues in any case. 😄

@bbqsrc bbqsrc closed this as completed Apr 10, 2021
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

3 participants