-
Notifications
You must be signed in to change notification settings - Fork 0
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
Config file envvar overrides #20
Conversation
src/configparser/field_coersion.rs
Outdated
where | ||
E: de::Error, | ||
{ | ||
Ok(FromStr::from_str(value).unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap here probably isn't ideal, I'd prefer returning a de::Error
variant (maybe with de::Error::invalid_value
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value
here is always going to be a &str
, so AFAICT there's no chance it will ever fail here. I stole this code from Serde's documentation examples so I'm also not really sure why this is doing the from_str
dance on an existing &str
to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed synchronously 11/05/24 -- approved
serde-yaml is deprecated and not maintained, serde-yml is the new fork Signed-off-by: Robert Detjens <[email protected]>
This file is autogenerated and we (users) don't care about the specifics of what has changed in it, only that it has. Signed-off-by: Robert Detjens <[email protected]>
Signed-off-by: Robert Detjens <[email protected]>
Signed-off-by: Robert Detjens <[email protected]>
2945c1d
to
ab6d6b8
Compare
Switch to building global and challenge configs with Figment instead of directly with Serde. Figment can merge multiple sources together before deserializing, including from environment variables.
This gets us envvar overrides for basically free. Any config in
rcds.yaml
can be set from envvars --BEAVERCDS_<path>
. Fields that are overridden from envvars can be omitted from the config file, since parsing happens after the merge. This allows users to not need to specify a placeholder value that's immediately replaced.Previously in #15 we agreed on
from_env:
subkeys, but that would need us to do all the parsing and substitution ourselves. With this approach this library does these overrides for free, and also gets us very good test capabilities for overrides and parsing and so on.examples:
Fixes #15.
Supersedes #18.