Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
94efc99d05
commit
bcdfaf2b2d
@ -407,6 +407,7 @@ mod assets;
|
|||||||
mod cargo_binstall;
|
mod cargo_binstall;
|
||||||
mod cargo_clean;
|
mod cargo_clean;
|
||||||
mod clap_sanity_test;
|
mod clap_sanity_test;
|
||||||
|
mod docker_cache;
|
||||||
mod mold;
|
mod mold;
|
||||||
mod sqlx;
|
mod sqlx;
|
||||||
|
|
||||||
@ -417,6 +418,7 @@ pub mod extensions {
|
|||||||
pub use super::cargo_binstall::*;
|
pub use super::cargo_binstall::*;
|
||||||
pub use super::cargo_clean::*;
|
pub use super::cargo_clean::*;
|
||||||
pub use super::clap_sanity_test::*;
|
pub use super::clap_sanity_test::*;
|
||||||
|
pub use super::docker_cache::*;
|
||||||
pub use super::mold::*;
|
pub use super::mold::*;
|
||||||
pub use super::sqlx::*;
|
pub use super::sqlx::*;
|
||||||
}
|
}
|
||||||
|
52
crates/cuddle-ci/src/rust_service/docker_cache.rs
Normal file
52
crates/cuddle-ci/src/rust_service/docker_cache.rs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use dagger_sdk::Container;
|
||||||
|
|
||||||
|
use crate::dagger_middleware::DaggerMiddleware;
|
||||||
|
|
||||||
|
use super::RustService;
|
||||||
|
|
||||||
|
pub struct DockerCache {
|
||||||
|
client: dagger_sdk::Query,
|
||||||
|
image_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DockerCache {
|
||||||
|
pub fn new(client: dagger_sdk::Query, image_name: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
client,
|
||||||
|
image_name: image_name.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl DaggerMiddleware for DockerCache {
|
||||||
|
async fn handle(&self, container: Container) -> eyre::Result<Container> {
|
||||||
|
container
|
||||||
|
.publish(format!(
|
||||||
|
"harbor.front.kjuulh.io/cache/{}:cache",
|
||||||
|
self.image_name
|
||||||
|
))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(container)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait DockerCacheExt {
|
||||||
|
fn with_docker_cache(&mut self) -> &mut Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DockerCacheExt for RustService {
|
||||||
|
fn with_docker_cache(&mut self) -> &mut Self {
|
||||||
|
self.with_stage(super::RustServiceStage::AfterRelease(Arc::new(
|
||||||
|
DockerCache::new(self.client.clone(), self.bin_name.clone()),
|
||||||
|
)));
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user