mod loader;
mod sections;
pub use loader::{ConfigError, TomlSyntaxError};
pub use sections::{
AdminSettings, AuditSettings, AuthSettings, BrandSettings, CacheSettings, DatabaseSettings,
DiskSettings, I18nSettings, JobsSettings, JwtSettings, LoggingSettings, MailSettings,
McpSettings, RoutesSettings, SecuritySettings, ServerSettings, Settings, SsoSettings,
StorageSettings, TenancySettings,
};
impl Settings {
pub fn load(env: &str) -> Result<Self, ConfigError> {
if let Some(overlay) = crate::test_settings::overlay() {
return Ok(overlay);
}
loader::load_with_root(std::path::Path::new("config"), env)
}
pub fn load_from(root: &std::path::Path, env: &str) -> Result<Self, ConfigError> {
loader::load_with_root(root, env)
}
pub fn load_from_env() -> Result<Self, ConfigError> {
Self::load(¤t_env_tier())
}
#[must_use]
pub fn current_env_tier() -> String {
current_env_tier()
}
}
fn current_env_tier() -> String {
crate::env::tier_from_env()
}
#[cfg(test)]
mod tier_tests {
use super::*;
#[test]
fn current_env_tier_defaults_to_dev_when_unset() {
if std::env::var("RUSTANGO_ENV").is_err() {
assert_eq!(Settings::current_env_tier(), "dev");
}
}
}