feat(rust-publish): with rust publish
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-08-12 21:29:24 +02:00
parent 5e604d7a10
commit 614a3bc305
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
2 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,4 @@
pub mod build;
pub mod publish;
pub mod source;
pub mod test;

View File

@ -0,0 +1,38 @@
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),
},
)
.await?;
println!("published: {}", image);
Ok(())
}
}