From 779ac244658d7641458ad669620c02f71037a8d3 Mon Sep 17 00:00:00 2001 From: MHamill98 <53518452+MHamill98@users.noreply.github.com> Date: Sat, 10 Aug 2019 23:12:06 +0100 Subject: Added function to tag an image (#187) * Added function to tag an image * Removed debug and println --- examples/imagetag.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/imagetag.rs (limited to 'examples') diff --git a/examples/imagetag.rs b/examples/imagetag.rs new file mode 100644 index 0000000..7ae78dd --- /dev/null +++ b/examples/imagetag.rs @@ -0,0 +1,27 @@ +// cargo run --example imagetag img repo tag + +use shiplift::{Docker, Image, TagOptions}; +use std::env; +use tokio::prelude::Future; + +fn main() { + env_logger::init(); + let docker = Docker::new(); + let img = env::args() + .nth(1) + .expect("You need to specify an image name"); + + let repo = env::args() + .nth(2) + .expect("You need to specify a repository name"); + + let tag = env::args().nth(3).expect("You need to specify a tag name"); + + let tag_opts = TagOptions::builder().repo(repo).tag(tag).build(); + + let image = Image::new(&docker, img); + + let fut = image.tag(&tag_opts).map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); +} -- cgit v1.2.3