-
Notifications
You must be signed in to change notification settings - Fork 253
feat(dotenv): Adding support for dotenv files #710
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 18750157020Details
💛 - Coveralls |
|
|
||
| /// Dotenv (parsed with `dotenvy`) | ||
| #[cfg(feature = "dotenv")] | ||
| Dotenv, |
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.
Does this work as another FileFormat / Source? I suspect there is a lot of design overlap with Environment that we'd want to make this functionality on that.
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.
This is another FileFormat. You can see the usage from the tests (added snippet for ref. here). It is similar to existing file formats. Also dotenvy dependency will take care of the overlap, if any. However I ensured OS env take precedence as per existing file formats.
let s = Config::builder()
.add_source(config::File::from_str(
r#"
FOO=bar
BAZ=qux
"#,
config::FileFormat::Dotenv,
))
.build()
.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.
FYI resolving conversations that aren't ready for it can make PR reviews more difficult on maintainers. You should be pretty confident that you understood the concern and responded to it as the maintainer expected to resolve it. That was not the case here.
Some traits of dotenv are
- Stringly typed (so is ini)
- Unstructured
Both of these characteristics are shared with Environment which has a lot of functionality for solving these problems. In fact, this is another form of environment variables! The only difference is it also shares some of the file loading characteristics of file formats.
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.
I've raised this (and other questions) at #16 (comment) as I prefer to work out high level designs in Issues rather than PRs.
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.
I've updated to strike a balance between dotenv ambitions and preferences of this repository.
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.
I'm not aware of any dotenv "ambitions" that come in conflict with "preferences of this repository". Also, for any "preferences" I'm giving, they are about fully supporting dotenv rather than doing it party way.
|
Feel free to modify your commits for how they should be merged |
bab1683 to
1f7f117
Compare
1f7f117 to
5017043
Compare
This adds support for dotenv file format. It is accomplished by using dotenvy crate. There's an open issue asking for this feature here #16.