Skip to content
Clone
030e59e
70 lines 2.1 KB Rust
use serde::{Deserialize, Serialize};
use crate::auth;
use crate::cache;
use crate::chat;
use crate::db;
use crate::email;
use crate::git;
use crate::issues;
use crate::jwt;
use crate::payment;
use crate::pow;
use crate::project;
use crate::queue;
use crate::rate_limit;
use crate::repo;
use crate::search;
use crate::space;
use crate::storage;
use crate::user;
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(default)]
pub struct AppConfig {
pub db: db::AppDatabaseSettings,
pub cache: cache::AppRedisSettings,
pub app_cache: cache::AppCacheSettings,
pub queue: queue::AppQueueSettings,
pub email: email::AppEmailSettings,
pub storage: storage::StorageSettings,
pub jwt: jwt::JwtSettings,
pub auth: auth::AuthConfig,
pub pow: pow::PowSettings,
pub issues: issues::IssueConfig,
pub project: project::ProjectConfig,
pub repo: repo::RepoConfig,
pub space: space::SpaceConfig,
pub user: user::UserConfig,
pub payment: payment::PaymentConfig,
pub rate_limit: rate_limit::RateLimitConfig,
pub search: search::AppSearchSettings,
pub chat: chat::AppChatSettings,
pub gateway: chat::GatewaySettings,
pub git_smart: git::SmartConfig,
pub git_ssh: git::GitSshConfig,
pub git_auth: git::GitAuthConfig,
pub git_sync: git::SyncSettings,
}
impl AppConfig {
pub fn validate(&self) -> Result<(), String> {
self.email.is_valid()?;
self.queue.is_valid()?;
self.search.is_valid()?;
if self.chat.topic_prefix != self.gateway.topic_prefix {
return Err(format!(
"chat.topic_prefix ({:?}) must equal gateway.topic_prefix ({:?})",
self.chat.topic_prefix, self.gateway.topic_prefix
));
}
if self.repo.git_storage_root.is_empty()
|| self.repo.lfs_storage_root.is_empty()
|| self.git_smart.git_storage_root.is_empty()
|| self.git_ssh.git_storage_root.is_empty()
{
return Err("git_storage_root / lfs_storage_root must not be empty".into());
}
Ok(())
}
}