2023-08-12 21:29:24 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
pub struct RustPublish {
|
|
|
|
client: Arc<dagger_sdk::Query>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RustPublish {
|
|
|
|
pub fn new(client: Arc<dagger_sdk::Query>) -> Self {
|
|
|
|
Self { client }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn publish(
|
|
|
|
&self,
|
|
|
|
image: impl Into<String>,
|
|
|
|
tag: impl Into<String>,
|
|
|
|
containers: impl IntoIterator<Item = dagger_sdk::Container>,
|
|
|
|
) -> eyre::Result<()> {
|
|
|
|
let mut ids = Vec::new();
|
|
|
|
for container in containers.into_iter() {
|
|
|
|
let id = container.id().await?;
|
|
|
|
ids.push(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
let image = self
|
|
|
|
.client
|
|
|
|
.container()
|
|
|
|
.publish_opts(
|
|
|
|
format!("{}:{}", image.into(), tag.into()),
|
|
|
|
dagger_sdk::ContainerPublishOpts {
|
|
|
|
platform_variants: Some(ids),
|
2023-10-21 12:45:33 +02:00
|
|
|
forced_compression: None,
|
|
|
|
media_types: None,
|
2023-08-12 21:29:24 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
println!("published: {}", image);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|