Open FaveroFerreira opened 2 years ago
Sounds like something for the "re-thinking" ideas list, thus I added it to the project. I guess we could add (optional) support for templating engines, which would easily resolve this feature request. Adding own logic that does such replacements would be overkill and out of scope for this crate, IMO, but I like the idea of exposing enough interfaces so that a user can easily add templating to the loading/parsing logic of config-rs!
Nice to hear that!
Comming from an Java + Spring background, maybe I am kinda biased towards using placeholders the way I pointed out on the issue description.
Just out of curiosity, do you have a different approach in mind? Maybe I can try and implement it.
I do not yet have anything specific in mind, no. If you like to experiment (emphasis on "experiment"), have a look at the rethinking issues. There's a branch linked somewhere where I am exploring my ideas.
I also have a background in Java+Spring. Spring has a very good configuration mechanism.
https://docs.spring.io/spring-boot/how-to/properties-and-configuration.html
Recently, I saw that the Rust ecosystem has a loco.rs project, which also supports placeholder configuration.
The implementation of loco.rs is a good reference.
Feature description
Ability to declare placeholder values in our configuration files that will be taken from the environment variables.
Use Case
Sometimes we do not decide how our environment variables will be named, so we don't get to define them with prefixes like
APP__
It would be nice if we could declare placeholders in our configuration files where the values should be taken from our environment variables.
Example: