jj_ryu/platform/
factory.rs1use crate::auth::{get_github_auth, get_gitlab_auth};
6use crate::error::Result;
7use crate::platform::{GitHubService, GitLabService, PlatformService};
8use crate::types::{Platform, PlatformConfig};
9
10pub async fn create_platform_service(config: &PlatformConfig) -> Result<Box<dyn PlatformService>> {
14 match config.platform {
15 Platform::GitHub => {
16 let auth = get_github_auth().await?;
17 Ok(Box::new(GitHubService::new(
18 &auth.token,
19 config.owner.clone(),
20 config.repo.clone(),
21 config.host.clone(),
22 )?))
23 }
24 Platform::GitLab => {
25 let auth = get_gitlab_auth(config.host.as_deref()).await?;
26 Ok(Box::new(GitLabService::new(
27 auth.token.clone(),
28 config.owner.clone(),
29 config.repo.clone(),
30 Some(auth.host),
31 )?))
32 }
33 }
34}