aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-10-20 16:48:24 +0200
committerMax Audron <audron@cocaine.farm>2021-10-20 16:49:07 +0200
commitfdac730c537a7e6ad57119112283d2eb55a570ad (patch)
tree32bdb849a69a23070289b870c3b22c7b68271f79
parentreplace sedregex crate (diff)
fix configuration not loading correctly on release builds
Diffstat (limited to '')
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/config.rs27
3 files changed, 23 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cd25dc2..e68d6e1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -133,7 +133,7 @@ checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "catinator"
-version = "1.5.0"
+version = "1.6.1"
dependencies = [
"anyhow",
"async-trait",
diff --git a/Cargo.toml b/Cargo.toml
index 41fe6a0..da941b2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "catinator"
-version = "1.5.0"
+version = "1.6.1"
authors = ["Max Audron <audron@cocaine.farm>"]
edition = "2018"
diff --git a/src/config.rs b/src/config.rs
index 1a88b95..4429184 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -5,6 +5,7 @@ use figment::{
value::{Dict, Map},
Error, Figment, Metadata, Profile, Provider,
};
+use tracing::debug;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)]
pub struct Config {
@@ -80,18 +81,32 @@ impl Config {
pub fn figment() -> Figment {
use figment::providers::Env;
- let figment = Figment::new();
+ let mut figment = Figment::new();
#[cfg(debug_assertions)]
const PROFILE: &str = "debug";
#[cfg(not(debug_assertions))]
const PROFILE: &str = "release";
- figment
- .merge(Toml::file("config.toml").nested())
- .merge(Toml::file("config.debug.toml").nested())
- .merge(Env::prefixed("CATINATOR_").split('_'))
- .select(PROFILE)
+ let config_file = if let Ok(path) = std::env::var("CATINATOR_CONFIG") {
+ path
+ } else {
+ "config.toml".to_string()
+ };
+
+ debug!("using config file: {}", config_file);
+
+ figment = figment
+ .merge(Toml::file(config_file).nested())
+ .merge(Env::prefixed("CATINATOR_").split('_'));
+
+ #[cfg(debug_assertions)]
+ {
+ debug!("sourcing debug config");
+ figment = figment.merge(Toml::file("config.debug.toml").nested());
+ }
+
+ figment.select(PROFILE)
}
}
td>remove gitlab moduleMax Audron-25/+0 2024-02-26update d3fus phone wg pubkeyMarcin Maselko-1/+1 2024-02-26added d3fus nass to wg configMarcin Maselko-0/+9 2024-02-21set minecraft memoryMax Audron-0/+1 2024-02-21add minecraft server and move palworld to games moduleMax Audron-3/+56 2024-02-21set network manually for ns serversMax Audron-0/+51 2024-02-20update nixpkgs-unstableMax Audron-3/+3 2024-02-19update d3fus fritzbox wg portMarcin Maselko-1/+1 2024-02-19add xonotic serverMax Audron-1/+10