diff --git a/crates/cuddle-ci/src/lib.rs b/crates/cuddle-ci/src/lib.rs index d0ae2d3..e40d12a 100644 --- a/crates/cuddle-ci/src/lib.rs +++ b/crates/cuddle-ci/src/lib.rs @@ -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 { + 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(()) + } + } +}