m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-18 09:53:43 -05:00

Fixed OpenSSL build errors on Alpine and changed the logging a bit

This commit is contained in:
Sergio
2024-09-15 20:21:13 +03:00
parent 663ca64cd7
commit bc86364e68
4 changed files with 79 additions and 291 deletions

View File

@@ -1,12 +1,9 @@
use std::collections::{HashMap, HashSet};
use chrono::Local;
use crate::{
debug,
docker::get_images_from_docker_daemon,
image::Image,
info,
registry::{check_auth, get_latest_digests, get_token},
utils::{new_reqwest_client, unsplit_image, CliConfig},
};
@@ -32,7 +29,6 @@ where
}
pub async fn get_all_updates(options: &CliConfig) -> Vec<(String, Option<bool>)> {
let start = Local::now().timestamp_millis();
let local_images = get_images_from_docker_daemon(options).await;
let mut image_map: HashMap<String, Option<String>> = HashMap::with_capacity(local_images.len());
for image in &local_images {
@@ -81,12 +77,6 @@ pub async fn get_all_updates(options: &CliConfig) -> Vec<(String, Option<bool>)>
None => result.push((img, None)),
}
});
let end = Local::now().timestamp_millis();
info!(
"✨ Checked {} images in {}ms",
local_images.len(),
end - start
);
result
}

View File

@@ -1,5 +1,6 @@
#[cfg(feature = "cli")]
use check::{get_all_updates, get_update};
use chrono::Local;
use clap::{Parser, Subcommand};
#[cfg(feature = "cli")]
use formatting::{print_raw_update, print_raw_updates, print_update, print_updates, Spinner};
@@ -95,13 +96,21 @@ async fn main() {
};
}
None => {
let start = Local::now().timestamp_millis();
match *raw || cli.verbose {
true => print_raw_updates(&get_all_updates(&cli_config).await),
true => {
let updates = get_all_updates(&cli_config).await;
let end = Local::now().timestamp_millis();
print_raw_updates(&updates);
info!("✨ Checked {} images in {}ms", updates.len(), end - start);
}
false => {
let spinner = Spinner::new();
let updates = get_all_updates(&cli_config).await;
spinner.succeed();
let end = Local::now().timestamp_millis();
print_updates(&updates, icons);
info!("✨ Checked {} images in {}ms", updates.len(), end - start);
}
};
}