feat(rust-publish): with rust publish
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
5e604d7a10
commit
614a3bc305
@ -1,3 +1,4 @@
|
|||||||
pub mod build;
|
pub mod build;
|
||||||
|
pub mod publish;
|
||||||
pub mod source;
|
pub mod source;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
38
crates/dagger-rust/src/publish.rs
Normal file
38
crates/dagger-rust/src/publish.rs
Normal 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(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user