Skip to content

Commit caae725

Browse files
committed
feat: use double underscore to split config env var names
For example, the env var `TORRUST_TRACKER__HTTP_API__ACCESS_TOKENS__ADMIN` would be the config option: ``` [http_api.access_tokens] admin = "MyAccessToken" ``` It uses `__` double underscore becuase dots are not allowed in Bash names. See: https://www.gnu.org/software/bash/manual/bash.html#Definitions ``` name A word consisting solely of letters, numbers, and underscores, and beginning with a letter or underscore. Names are used as shell variable and function names. Also referred to as an identifier. ```
1 parent b3a1442 commit caae725

File tree

1 file changed

+2
-2
lines changed
  • packages/configuration/src/v1

1 file changed

+2
-2
lines changed

packages/configuration/src/v1/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl Configuration {
406406
pub fn load(info: &Info) -> Result<Configuration, Error> {
407407
let figment = Figment::new()
408408
.merge(Toml::string(&info.tracker_toml))
409-
.merge(Env::prefixed("TORRUST_TRACKER_"));
409+
.merge(Env::prefixed("TORRUST_TRACKER__").split("__"));
410410

411411
let mut config: Configuration = figment.extract()?;
412412

@@ -553,7 +553,7 @@ mod tests {
553553
#[test]
554554
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin() {
555555
figment::Jail::expect_with(|jail| {
556-
jail.set_env("TORRUST_TRACKER_HTTP_API.ACCESS_TOKENS.ADMIN", "NewToken");
556+
jail.set_env("TORRUST_TRACKER__HTTP_API__ACCESS_TOKENS__ADMIN", "NewToken");
557557

558558
let info = Info {
559559
tracker_toml: default_config_toml(),

0 commit comments

Comments
 (0)