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

Add getter for getting a &mut Value from Config #165

Closed
wants to merge 3 commits into from

Conversation

matthiasbeyer
Copy link
Member

This is a (maybe possible) solution for #163

This is, of course, not as nice as it could be, because it exposes interior of this crate to the user.
I'm currently experimenting with these patches in my source, to see whether such a thing is feasible at all.

Feel free to ignore until I reached a state where it works, then we can debate over it.

This function can be used to alter values while loading stuff into the
Config object.

Signed-off-by: Matthias Beyer <[email protected]>
Signed-off-by: Matthias Beyer <[email protected]>
@matthiasbeyer
Copy link
Member Author

matthiasbeyer commented Feb 19, 2021

Okay, so I was able to confirm that this is a possible way to implement the feature I need.

Here's how I use this feature now: https://git.beyermatthi.as/butido/commit/?h=pathes-to-absolute&id=370d6bc6e5140d5fa26c0c7029bc1269e9b0c9ad

I think we can start a discussion about this.


Please note that my patch linked above is not perfect. As you can see if you browse the source file as whole, I'm recursively loading files and the patch has issues with that because later recursion overwrites prior steps.
Still, the approach is the way to go with this change to config-rs.

Edit:
Argh, the refresh() call during merging is an issue in this case, because in later recursion, the refresh call causes my fixing of pathes to be overwritten. Dangit!

@matthiasbeyer matthiasbeyer marked this pull request as ready for review February 19, 2021 08:47
@matthiasbeyer
Copy link
Member Author

btw, it looks like the CI failure is not caused by me, is it?

@matthiasbeyer
Copy link
Member Author

Superseded and thus not relevant anymore.

matthiasbeyer added a commit to science-computing/butido that referenced this pull request Mar 10, 2021
This patch ensures that pathes for patches are always relative to the repository
root, when loading the packages layered from the repository.

The problem is well described in the comment in the code, so this commit message
ends here.

This patch was written using an proposed feature for the config-rs dependency:
rust-cli/config-rs#165

This PR added a `Config::get_value_mut()` function and exported the
`config::value::ValueKind` type in config-rs public API.

Signed-off-by: Matthias Beyer <[email protected]>
Tested-by: Matthias Beyer <[email protected]>
@matthiasbeyer matthiasbeyer deleted the get-value-mut branch March 16, 2021 07:51
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

Successfully merging this pull request may close these issues.

1 participant