Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
88a467780c
commit
4e380b17c0
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user