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
47
48
49
50
51
52
53
54
55
56
57
58
59
use anyhow::{anyhow, Result};
pub mod config;
mod runtime;
extern crate pretty_env_logger;
#[macro_use]
extern crate log;
pub async fn run(cfg: config::Config) -> Result<()> {
pretty_env_logger::formatted_builder()
.parse_filters(&cfg.log_level.clone())
.init();
let rt = if let Some(runtime) = runtime::set(&cfg.socket).await {
runtime
} else {
return Err(anyhow!("❌ no valid container runtime"));
};
let container = match runtime::container::new(cfg.image, rt) {
Ok(i) => i,
Err(e) => {
return Err(anyhow!("❌ error building the image: {}", e));
}
};
match container
.pull(cfg.username, cfg.password, cfg.force_pull)
.await
{
Ok(_) => {}
Err(e) => {
return Err(anyhow!("❌ error building the image: {}", e));
}
}
match container
.copy_files(cfg.content_path, cfg.download_path, cfg.write_to_stdout)
.await
{
Ok(_) => {}
Err(e) => {
return Err(anyhow!("❌ error copying the image's files: {}", e));
}
}
Ok(())
}