feat(config): User must specify a directory to store data

Closes kemitix/git-next#55
This commit is contained in:
Paul Campbell 2024-04-19 18:49:03 +01:00
parent 704853017b
commit 16dc823f58

View file

@ -17,6 +17,7 @@ use crate::filesystem::FileSystem;
#[derive(Debug, PartialEq, Eq, Deserialize)] #[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct ServerConfig { pub struct ServerConfig {
webhook: Webhook, webhook: Webhook,
storage: ServerStorage,
forge: HashMap<String, ForgeConfig>, forge: HashMap<String, ForgeConfig>,
} }
impl ServerConfig { impl ServerConfig {
@ -56,6 +57,12 @@ impl AsRef<str> for WebhookUrl {
} }
} }
/// The directory to store server data, such as cloned repos
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
pub struct ServerStorage {
path: PathBuf,
}
/// Mapped from `.git-next.toml` file in target repo /// Mapped from `.git-next.toml` file in target repo
/// Is also derived from the optional parameters in `git-next-server.toml` at /// Is also derived from the optional parameters in `git-next-server.toml` at
/// `forge.{forge}.repos.{repo}.(main|next|dev)` /// `forge.{forge}.repos.{repo}.(main|next|dev)`
@ -394,6 +401,9 @@ mod tests {
[webhook] [webhook]
url = "http://localhost:9909/webhook" url = "http://localhost:9909/webhook"
[storage]
path = "/opt/git-next/data"
[forge.default] [forge.default]
forge_type = "MockForge" forge_type = "MockForge"
hostname = "git.example.net" hostname = "git.example.net"
@ -418,6 +428,9 @@ mod tests {
webhook: Webhook { webhook: Webhook {
url: "http://localhost:9909/webhook".to_string(), url: "http://localhost:9909/webhook".to_string(),
}, },
storage: ServerStorage {
path: "/opt/git-next/data".into(),
},
forge: HashMap::from([( forge: HashMap::from([(
"default".to_string(), "default".to_string(),
ForgeConfig { ForgeConfig {