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> {
match (
std::env::var("REGISTRY_CACHE_USERNAME"),
std::env::var("REGISTRY_CACHE_PASSWORD"),
) {
(Ok(username), Ok(password)) => {
let url = format!("harbor.front.kjuulh.io/cache/{}:cache", self.image_name);
let secret = self.client.set_secret("REGISTRY_CACHE_PASSWORD", password);
container container
.publish(format!( .with_registry_auth(&url, &username, secret)
"harbor.front.kjuulh.io/cache/{}:cache", .publish_opts(
self.image_name &url,
)) dagger_sdk::ContainerPublishOpts {
forced_compression: Some(dagger_sdk::ImageLayerCompression::Gzip),
media_types: Some(dagger_sdk::ImageMediaTypes::OCIMediaTypes),
platform_variants: None,
},
)
.await?; .await?;
}
_ => {
eprintln!("failed to find REGISTRY_CACHE_USERNAME or REGISTRY_CACHE_PASSWORD");
}
}
Ok(container) Ok(container)
} }