feat: add cuddle_cli
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 23:41:59 +01:00
parent 7363871ffb
commit 2b4a67e38c
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
2 changed files with 51 additions and 0 deletions

View File

@ -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::*;

View File

@ -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<Container> {
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
}
}