-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df9e408
commit 166b398
Showing
14 changed files
with
592 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
use futures::TryStreamExt; | ||
use shiplift::Docker; | ||
use std::{env, path}; | ||
use tokio::prelude::{Future, Stream}; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let id = env::args() | ||
.nth(1) | ||
.expect("Usage: cargo run --example containercopyfrom -- <container> <path in container>"); | ||
let path = env::args() | ||
.nth(2) | ||
.expect("Usage: cargo run --example containercopyfrom -- <container> <path in container>"); | ||
let fut = docker | ||
|
||
match docker | ||
.containers() | ||
.get(&id) | ||
.copy_from(path::Path::new(&path)) | ||
.collect() | ||
.and_then(|stream| { | ||
let tar = stream.concat(); | ||
let mut archive = tar::Archive::new(tar.as_slice()); | ||
archive.unpack(env::current_dir()?)?; | ||
.try_concat() | ||
.await | ||
{ | ||
Ok(tar) => { | ||
let mut archive = tar::Archive::new(&tar); | ||
archive.unpack(env::current_dir().unwrap()).unwrap(); | ||
Ok(()) | ||
}) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
} | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
use shiplift::{ContainerOptions, Docker}; | ||
use std::env; | ||
use tokio::prelude::Future; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let image = env::args() | ||
.nth(1) | ||
.expect("You need to specify an image name"); | ||
let fut = docker | ||
|
||
match docker | ||
.containers() | ||
.create(&ContainerOptions::builder(image.as_ref()).build()) | ||
.map(|info| println!("{:?}", info)) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
.await | ||
{ | ||
Ok(info) => println!("{:?}", info), | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
use shiplift::Docker; | ||
use std::env; | ||
use tokio::prelude::Future; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let id = env::args() | ||
.nth(1) | ||
.expect("You need to specify an container id"); | ||
let fut = docker | ||
.containers() | ||
.get(&id) | ||
.delete() | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
|
||
if let Err(e) = docker.containers().get(&id).delete().await { | ||
eprintln!("Error: {}", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
use shiplift::Docker; | ||
use std::env; | ||
use tokio::prelude::Future; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let id = env::args() | ||
.nth(1) | ||
.expect("Usage: cargo run --example containerinspect -- <container>"); | ||
let fut = docker | ||
.containers() | ||
.get(&id) | ||
.inspect() | ||
.map(|container| println!("{:#?}", container)) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
|
||
match docker.containers().get(&id).inspect().await { | ||
Ok(container) => println!("{:#?}", container), | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
use shiplift::Docker; | ||
use tokio::prelude::Future; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
env_logger::init(); | ||
let docker = Docker::new(); | ||
let fut = docker | ||
.containers() | ||
.list(&Default::default()) | ||
.map(|containers| { | ||
match docker.containers().list(&Default::default()).await { | ||
Ok(containers) => { | ||
for c in containers { | ||
println!("container -> {:#?}", c) | ||
} | ||
}) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
|
||
tokio::run(fut); | ||
} | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
use futures::StreamExt; | ||
use shiplift::{BuildOptions, Docker}; | ||
use std::env; | ||
use tokio::prelude::{Future, Stream}; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let path = env::args().nth(1).expect("You need to specify a path"); | ||
|
||
let fut = docker | ||
match docker | ||
.images() | ||
.build(&BuildOptions::builder(path).tag("shiplift_test").build()) | ||
.for_each(|output| { | ||
println!("{:?}", output); | ||
Ok(()) | ||
}) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
|
||
tokio::run(fut); | ||
{ | ||
Ok(output) => { | ||
while let Some(chunk_result) = output.next().await { | ||
match chunk_result { | ||
Ok(output) => println!("{:?}", output), | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
use shiplift::Docker; | ||
use std::env; | ||
use tokio::prelude::Future; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::new(); | ||
let img = env::args() | ||
.nth(1) | ||
.expect("You need to specify an image name"); | ||
let fut = docker | ||
.images() | ||
.get(&img[..]) | ||
.delete() | ||
.map(|statuses| { | ||
match docker.images().get(&img).delete().await { | ||
Ok(statuses) => { | ||
for status in statuses { | ||
println!("{:?}", status); | ||
} | ||
}) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
} | ||
Err(e) => eprintln!("Error: {}", e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.