forked from softprops/shiplift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a registry authentication. (softprops#157)
- Loading branch information
Showing
5 changed files
with
226 additions
and
16 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,28 @@ | ||
// cargo run --example imagepull_auth busybox username password | ||
|
||
use shiplift::{Docker, PullOptions, RegistryAuth}; | ||
use std::env; | ||
use tokio::prelude::{Future, Stream}; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
let docker = Docker::new(); | ||
let img = env::args() | ||
.nth(1) | ||
.expect("You need to specify an image name"); | ||
let username = env::args().nth(2).expect("You need to specify an username"); | ||
let password = env::args().nth(3).expect("You need to specify a password"); | ||
let auth = RegistryAuth::builder() | ||
.username(username) | ||
.password(password) | ||
.build(); | ||
let fut = docker | ||
.images() | ||
.pull(&PullOptions::builder().image(img).auth(auth).build()) | ||
.for_each(|output| { | ||
println!("{:?}", output); | ||
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
Oops, something went wrong.