From 2832d8cb93c13201cbc717b51a6443c5002eaac6 Mon Sep 17 00:00:00 2001 From: strawberry Date: Mon, 4 Mar 2024 21:57:53 -0500 Subject: [PATCH] make CONDUIT_CONFIG optional retains compatibility for container users who set it to empty. if the variable is unspecified, it will use the CONDUIT_ variables as normal. Signed-off-by: strawberry --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index d92e866e..baa9fc98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,15 +63,18 @@ struct Args; async fn main() { Args::parse(); // Initialize config - let raw_config = + let raw_config = if Env::var("CONDUIT_CONFIG").is_some() { Figment::new() .merge( Toml::file(Env::var("CONDUIT_CONFIG").expect( - "The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml", + "The CONDUIT_CONFIG environment variable was set but appears to be invalid. This should be set to the path to a valid TOML file, an empty string (for compatibility), or removed/unset entirely.", )) .nested(), ) - .merge(Env::prefixed("CONDUIT_").global()); + .merge(Env::prefixed("CONDUIT_").global()) + } else { + Figment::new().merge(Env::prefixed("CONDUIT_").global()) + }; let config = match raw_config.extract::() { Ok(s) => s,