mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-12 08:01:04 +00:00
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use anyhow::Context;
|
|
use helpers::git::CloneArgs;
|
|
use serde_json::json;
|
|
use types::{Log, Server};
|
|
|
|
use crate::PeripheryClient;
|
|
|
|
impl PeripheryClient {
|
|
pub async fn clone_repo(
|
|
&self,
|
|
server: &Server,
|
|
clone_args: impl Into<CloneArgs>,
|
|
) -> anyhow::Result<Vec<Log>> {
|
|
let clone_args: CloneArgs = clone_args.into();
|
|
self.post_json(server, "/git/clone", &clone_args)
|
|
.await
|
|
.context("failed to clone repo on periphery")
|
|
}
|
|
|
|
pub async fn pull_repo(
|
|
&self,
|
|
server: &Server,
|
|
name: &str,
|
|
branch: &Option<String>,
|
|
) -> anyhow::Result<Log> {
|
|
self.post_json(
|
|
server,
|
|
"/git/pull",
|
|
&json!({ "name": name, "branch": branch }),
|
|
)
|
|
.await
|
|
.context("failed to pull repo on periphery")
|
|
}
|
|
|
|
pub async fn delete_repo(&self, server: &Server, build_name: &str) -> anyhow::Result<Log> {
|
|
self.post_json(server, "/git/delete", &json!({ "name": build_name }))
|
|
.await
|
|
.context("failed to delete repo on periphery")
|
|
}
|
|
}
|