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 tracing::error;
use crate::server::{
config::{ForgeType, RepoDetails},
forge, gitforge,
};
use crate::server::{config::RepoDetails, gitforge};
use super::{LoadedConfig, RepoActor};
pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
let config = match details.config {
Some(config) => config,
None => {
let config = match details.forge.forge_type {
#[cfg(feature = "forgejo")]
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;
}
}
pub async fn load(repo_details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
let config = match crate::server::config::load::load(&repo_details, &forge).await {
Ok(config) => config,
Err(err) => {
error!(?err, "Failed to load config");
return;
}
};
addr.do_send(LoadedConfig(config));

View file

@ -1,3 +1,5 @@
pub mod load;
use std::{
collections::HashMap,
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 config;
pub mod forge;
pub mod gitforge;
pub mod types;