From 3ac4894d68bb4a7a0a78ce1b4b85bf7ae8aa5d9d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 7 Apr 2024 19:41:56 +0100 Subject: [PATCH] feat(config): add ForgeDetails and RepoDetails types --- src/server/config.rs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/server/config.rs b/src/server/config.rs index ff0f2fc9..9e9c468e 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -39,7 +39,48 @@ impl Forge { } } -#[derive(Debug, PartialEq, Eq, Deserialize)] +#[derive(Clone)] +pub struct ForgeName(pub String); +impl Display for ForgeName { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} +pub struct Hostname(pub String); +pub struct User(pub String); +pub struct ForgeDetails { + pub name: ForgeName, + pub forge_type: ForgeType, + pub hostname: Hostname, + pub user: User, + // API Token + // Private SSH Key Path +} +impl From<(&ForgeName, &Forge)> for ForgeDetails { + fn from(forge: (&ForgeName, &Forge)) -> Self { + Self { + name: forge.0.clone(), + forge_type: forge.1.forge_type.clone(), + hostname: Hostname(forge.1.hostname.clone()), + user: User(forge.1.user.clone()), + } + } +} +#[derive(Clone)] +pub struct RepoName(pub String); +impl Display for RepoName { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} +pub struct RepoPath(pub String); +pub struct RepoDetails { + pub name: RepoName, + pub path: RepoPath, + pub forge: ForgeDetails, +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize)] pub enum ForgeType { ForgeJo, // Gitea,