git-next/crates/config/src/forge_details.rs
Paul Campbell 206e64cd5b
Some checks failed
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Rust / build (push) Has been cancelled
feat: Webhook query paths include forge alias
This allows for more than one forge to be configured and for the webhook
to correctly route incoming messages.
2024-05-29 19:35:50 +01:00

41 lines
1.1 KiB
Rust

use crate::{ApiToken, ForgeAlias, ForgeConfig, ForgeType, Hostname, User};
/// The derived information about a Forge, used to create interactions with it
#[derive(Clone, Default, Debug, derive_more::Constructor, derive_with::With)]
pub struct ForgeDetails {
forge_alias: ForgeAlias,
forge_type: ForgeType,
hostname: Hostname,
user: User,
token: ApiToken,
// API Token
// Private SSH Key Path
}
impl ForgeDetails {
pub const fn forge_alias(&self) -> &ForgeAlias {
&self.forge_alias
}
pub const fn forge_type(&self) -> ForgeType {
self.forge_type
}
pub const fn hostname(&self) -> &Hostname {
&self.hostname
}
pub const fn user(&self) -> &User {
&self.user
}
pub const fn token(&self) -> &ApiToken {
&self.token
}
}
impl From<(&ForgeAlias, &ForgeConfig)> for ForgeDetails {
fn from(forge: (&ForgeAlias, &ForgeConfig)) -> Self {
Self {
forge_alias: forge.0.clone(),
forge_type: forge.1.forge_type(),
hostname: forge.1.hostname(),
user: forge.1.user(),
token: forge.1.token(),
}
}
}