From 071e7de44d9723ffd40556c3d295c19df6cacc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 11 Jan 2023 13:07:27 +0000 Subject: [PATCH] bugfix: always read values of environmental config options regardless of whether they have the default values or not --- common/config/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/config/src/lib.rs b/common/config/src/lib.rs index 9e778840cd..7e5f5464dd 100644 --- a/common/config/src/lib.rs +++ b/common/config/src/lib.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 use handlebars::Handlebars; -use network_defaults::mainnet::read_var_if_not_default; use network_defaults::var_names::CONFIGURED; use serde::de::DeserializeOwned; use serde::Serialize; @@ -155,10 +154,12 @@ pub trait OptionalSet { ::Err: Debug, Self: Sized, { + // if explicit value is provided, use it if let Some(val) = val { return f(self, val); } else if std::env::var(CONFIGURED).is_ok() { - if let Some(raw) = read_var_if_not_default(env_var) { + // otherwise if environmental variable is configured, fallback to that and parse it from string + if let Ok(raw) = std::env::var(env_var) { return f( self, raw.parse().unwrap_or_else(|err| { @@ -186,10 +187,12 @@ pub trait OptionalSet { G: Fn(&str) -> T, Self: Sized, { + // if explicit value is provided, use it if let Some(val) = val { return f(self, val); } else if std::env::var(CONFIGURED).is_ok() { - if let Some(raw) = read_var_if_not_default(env_var) { + // otherwise if environmental variable is configured, fallback to that + if let Ok(raw) = std::env::var(env_var) { return f(self, parser(&raw)); } }