-
Notifications
You must be signed in to change notification settings - Fork 0
/
image-list.rs
46 lines (33 loc) · 1.03 KB
/
image-list.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#[path = "example_utils/lib.rs"]
mod example_utils;
use std::process::ExitCode;
use passivized_docker_engine_client::{DockerEngineClient};
use passivized_test_support::cli;
use log::*;
use example_utils::errors::ExampleError;
const PRINT_LIMIT: usize = 10;
#[tokio::main]
async fn main() -> ExitCode {
cli::run(run).await
}
async fn run() -> Result<(), ExampleError> {
let dec = DockerEngineClient::new()?;
info!("Connecting to {}", dec);
info!("Getting image list");
let images = dec.images().list().await?;
info!("Found {} images", images.len());
let mut printed = 0;
for (i, image) in images.iter().enumerate() {
if image.repo_tags.iter().filter(|item| item.to_string() != "<none>:<none>".to_string()).count() > 0 {
info!("Image {}: {:?}", i, image.id);
for repo_tag in &image.repo_tags {
info!(" {}", repo_tag);
}
printed = printed + 1;
}
if printed >= PRINT_LIMIT {
break;
}
}
Ok(())
}