diff options
Diffstat (limited to 'examples/volumecreate.rs')
-rw-r--r-- | examples/volumecreate.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/volumecreate.rs b/examples/volumecreate.rs new file mode 100644 index 0000000..d955abe --- /dev/null +++ b/examples/volumecreate.rs @@ -0,0 +1,32 @@ +extern crate shiplift; +extern crate tokio; + +use shiplift::builder::VolumeCreateOptions; +use shiplift::Docker; +use std::collections::HashMap; +use std::env; +use tokio::prelude::Future; + +fn main() { + let docker = Docker::new(); + let volumes = docker.volumes(); + + let volume_name = env::args() + .nth(1) + .expect("You need to specify an volume name"); + + let mut labels = HashMap::new(); + labels.insert("com.github.softprops", "shiplift"); + + let fut = volumes + .create( + &VolumeCreateOptions::builder() + .name(volume_name.as_ref()) + .labels(&labels) + .build(), + ) + .map(|info| println!("{:?}", info)) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); +} |