refactor: move server config loading out of forgejo module

Delete empty modules left over
This commit is contained in:
Paul Campbell 2024-04-18 20:26:19 +01:00
parent 0bfa1df875
commit 50a969ede6
9 changed files with 9 additions and 55 deletions

View file

@ -1,30 +1,16 @@
use actix::prelude::*; use actix::prelude::*;
use tracing::error; use tracing::error;
use crate::server::{ use crate::server::{config::RepoDetails, gitforge};
config::{ForgeType, RepoDetails},
forge, gitforge,
};
use super::{LoadedConfig, RepoActor}; use super::{LoadedConfig, RepoActor};
pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) { pub async fn load(repo_details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
let config = match details.config { let config = match crate::server::config::load::load(&repo_details, &forge).await {
Some(config) => config, Ok(config) => config,
None => { Err(err) => {
let config = match details.forge.forge_type { error!(?err, "Failed to load config");
#[cfg(feature = "forgejo")] return;
ForgeType::ForgeJo => forge::forgejo::config::load(&details, &forge).await,
#[cfg(test)]
ForgeType::MockForge => forge::mock::config::load(&details, &forge).await,
};
match config {
Ok(config) => config,
Err(err) => {
error!(?err, "Failed to load config");
return;
}
}
} }
}; };
addr.do_send(LoadedConfig(config)); addr.do_send(LoadedConfig(config));

View file

@ -1,3 +1,5 @@
pub mod load;
use std::{ use std::{
collections::HashMap, collections::HashMap,
fmt::{Display, Formatter}, fmt::{Display, Formatter},

View file

@ -1 +0,0 @@
pub mod config;

View file

@ -1,14 +0,0 @@
use terrors::OneOf;
use crate::server::{
config::RepoConfig,
forge::forgejo::config::RepoConfigValidationErrors,
gitforge::{self, ForgeFileError},
};
pub async fn load(
_details: &crate::server::config::RepoDetails,
_forge: &gitforge::Forge,
) -> Result<RepoConfig, OneOf<(ForgeFileError, toml::de::Error, RepoConfigValidationErrors)>> {
todo!()
}

View file

@ -1 +0,0 @@
pub mod config;

View file

@ -1,7 +0,0 @@
#[cfg(feature = "forgejo")]
pub mod forgejo;
#[cfg(test)]
pub mod mock;
#[cfg(test)]
mod tests;

View file

@ -1,10 +0,0 @@
use kxio::network;
use crate::server::gitforge;
#[test]
const fn test_is_send() {
const fn assert_send<T: Send>() {}
assert_send::<gitforge::CommitHistories>();
assert_send::<network::NetworkError>();
}

View file

@ -1,6 +1,5 @@
mod actors; mod actors;
mod config; mod config;
pub mod forge;
pub mod gitforge; pub mod gitforge;
pub mod types; pub mod types;