forked from softprops/shiplift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add 'copy_from' function to 'Container' * Run clippy * Update deps
- Loading branch information
Showing
7 changed files
with
87 additions
and
27 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use shiplift::Docker; | ||
use std::{env, path}; | ||
use tokio::prelude::{Future, Stream}; | ||
|
||
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 | ||
.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()?)?; | ||
Ok(()) | ||
}) | ||
.map_err(|e| eprintln!("Error: {}", e)); | ||
tokio::run(fut); | ||
} |
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
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
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