diff --git a/crates/cuddle-ci/src/rust_service.rs b/crates/cuddle-ci/src/rust_service.rs index 96aa5a9..457fd3d 100644 --- a/crates/cuddle-ci/src/rust_service.rs +++ b/crates/cuddle-ci/src/rust_service.rs @@ -417,6 +417,7 @@ mod assets; mod cargo_binstall; mod cargo_clean; mod clap_sanity_test; +mod cuddle_cli; mod docker_cache; mod docker_cli; mod mold; @@ -430,6 +431,7 @@ pub mod extensions { pub use super::cargo_binstall::*; pub use super::cargo_clean::*; pub use super::clap_sanity_test::*; + pub use super::cuddle_cli::*; pub use super::docker_cache::*; pub use super::docker_cli::*; pub use super::mold::*; diff --git a/crates/cuddle-ci/src/rust_service/cuddle_cli.rs b/crates/cuddle-ci/src/rust_service/cuddle_cli.rs new file mode 100644 index 0000000..6e24ddf --- /dev/null +++ b/crates/cuddle-ci/src/rust_service/cuddle_cli.rs @@ -0,0 +1,49 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use dagger_sdk::Container; + +use crate::dagger_middleware::DaggerMiddleware; + +use super::RustService; + +pub struct CuddleCli { + client: dagger_sdk::Query, +} + +impl CuddleCli { + pub fn new(client: dagger_sdk::Query) -> Self { + Self { client } + } +} + +#[async_trait] +impl DaggerMiddleware for CuddleCli { + async fn handle(&self, container: Container) -> eyre::Result { + let cuddle = self + .client + .container() + .from("kasperhermansen/cuddle:latest"); + + Ok(container.with_file( + "/usr/local/bin/cuddle", + cuddle.file("/usr/local/cargo/cuddle"), + )) + } +} + +pub trait CuddleCliExt { + fn with_cuddle_cli(&mut self) -> &mut Self { + self + } +} + +impl CuddleCliExt for RustService { + fn with_cuddle_cli(&mut self) -> &mut Self { + self.with_stage(super::RustServiceStage::BeforePackage(Arc::new( + CuddleCli::new(self.client.clone()), + ))); + + self + } +}