feat: set registry
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 2023-12-01 21:59:26 +01:00
parent 88a467780c
commit 4e380b17c0
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394

View File

@ -24,12 +24,30 @@ impl DockerCache {
#[async_trait] #[async_trait]
impl DaggerMiddleware for DockerCache { impl DaggerMiddleware for DockerCache {
async fn handle(&self, container: Container) -> eyre::Result<Container> { async fn handle(&self, container: Container) -> eyre::Result<Container> {
container match (
.publish(format!( std::env::var("REGISTRY_CACHE_USERNAME"),
"harbor.front.kjuulh.io/cache/{}:cache", std::env::var("REGISTRY_CACHE_PASSWORD"),
self.image_name ) {
)) (Ok(username), Ok(password)) => {
.await?; let url = format!("harbor.front.kjuulh.io/cache/{}:cache", self.image_name);
let secret = self.client.set_secret("REGISTRY_CACHE_PASSWORD", password);
container
.with_registry_auth(&url, &username, secret)
.publish_opts(
&url,
dagger_sdk::ContainerPublishOpts {
forced_compression: Some(dagger_sdk::ImageLayerCompression::Gzip),
media_types: Some(dagger_sdk::ImageMediaTypes::OCIMediaTypes),
platform_variants: None,
},
)
.await?;
}
_ => {
eprintln!("failed to find REGISTRY_CACHE_USERNAME or REGISTRY_CACHE_PASSWORD");
}
}
Ok(container) Ok(container)
} }