tci/src/cfg.rs

24 lines
489 B
Rust
Raw Normal View History

2024-02-14 20:06:49 +01:00
#[derive(Debug, Default, serde::Deserialize)]
2024-02-15 03:04:53 +01:00
pub struct TciConfig {
2024-02-14 20:06:49 +01:00
#[serde(default)]
pub allow_all: bool,
#[serde(default)]
2024-02-15 03:04:53 +01:00
pub branch: Option<String>,
2024-02-14 20:06:49 +01:00
#[serde(default)]
2024-02-15 03:04:53 +01:00
pub hooks: Vec<String>,
2024-02-14 20:06:49 +01:00
}
2024-02-15 03:04:53 +01:00
impl TciConfig {
pub fn load() -> Result<Self, toml::de::Error> {
let config_path = std::env::var("TCI_CONFIG")
2024-02-15 03:12:00 +01:00
.unwrap_or_else(|_| "/etc/tci/config.toml".into());
2024-02-15 03:04:53 +01:00
let cfg_raw = std::fs::read_to_string(config_path)
.unwrap_or_default();
toml::from_str(&cfg_raw)
}
}