Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
88a467780c
commit
4e380b17c0
@ -24,12 +24,30 @@ impl DockerCache {
|
||||
#[async_trait]
|
||||
impl DaggerMiddleware for DockerCache {
|
||||
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
|
||||
.publish(format!(
|
||||
"harbor.front.kjuulh.io/cache/{}:cache",
|
||||
self.image_name
|
||||
))
|
||||
.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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user