use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(default)]
pub struct CacheConfig {
pub issue_ttl_minutes: i64,
pub repo_ttl_hours: i64,
pub curated_repos_url: String,
pub file_eviction_days: i64,
}
impl Default for CacheConfig {
fn default() -> Self {
Self {
issue_ttl_minutes: crate::cache::DEFAULT_ISSUE_TTL_MINS,
repo_ttl_hours: crate::cache::DEFAULT_REPO_TTL_HOURS,
curated_repos_url:
"https://raw.githubusercontent.com/clouatre-labs/aptu/main/data/curated-repos.json"
.to_string(),
file_eviction_days: 7,
}
}
}
impl CacheConfig {
pub fn validate(&self) -> Result<(), String> {
if self.file_eviction_days <= 0 {
return Err(format!(
"file_eviction_days must be > 0, got {}",
self.file_eviction_days
));
}
Ok(())
}
}
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(default)]
pub struct ReposConfig {
pub curated: bool,
#[serde(default)]
pub dco_signoff: bool,
}
impl Default for ReposConfig {
fn default() -> Self {
Self {
curated: true,
dco_signoff: false,
}
}
}