feat: add releaser
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-01-28 19:20:38 +01:00
parent 926199a487
commit 5378b5f537
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -7,3 +7,61 @@ pub mod dagger_middleware;
pub mod node_service;
pub mod rust_lib;
pub mod rust_service;
pub mod cuddle_releaser {
use async_trait::async_trait;
use crate::{rust_service::RustService, MainAction};
pub struct CuddleReleaser {
client: dagger_sdk::Query,
options: CuddleReleaserOptions,
}
pub struct CuddleReleaserOptions {
upstream: String,
folder: String,
cluster: String,
namespace: String,
app: String,
}
impl CuddleReleaser {
pub async fn new(
client: dagger_sdk::Query,
options: CuddleReleaserOptions,
) -> eyre::Result<Self> {
Ok(Self { client, options })
}
}
#[async_trait]
impl MainAction for CuddleReleaser {
async fn execute_main(&self) -> eyre::Result<()> {
let client = self.client;
let cuddle_releaser_image = "docker.io/kasperhermansen:cuddle-releaser:main-1706438736";
let folder = client.host().directory(self.options.folder);
let cuddle_releaser = client
.container()
.from(cuddle_releaser_image)
.with_mounted_directory("/mnt/templates", folder);
cuddle_releaser
.with_exec(vec![
"cuddle-releaser",
"release",
&format!("--upstream={}", self.options.upstream),
&format!("--folder={}", "/mnt/templates"),
&format!("--cluster={}", self.options.cluster),
&format!("--namespace={}", self.options.namespace),
&format!("--app={}", self.options.app),
])
.sync()?;
Ok(())
}
}
}