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

feat: add new filter for in use images to web ui

This commit is contained in:
Raphaël C.
2025-04-27 17:48:11 +02:00
committed by Sergio
parent 4b3bf9bd8f
commit c8229d7370
14 changed files with 170 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
docker::get_images_from_docker_daemon,
docker::{get_images_from_docker_daemon, get_in_use_images},
http::Client,
registry::{check_auth, get_token},
structs::{image::Image, update::Update},
@@ -99,6 +99,15 @@ pub async fn get_updates(
// Get local images
ctx.logger.debug("Retrieving images to be checked");
let mut images = get_images_from_docker_daemon(ctx, references).await;
let in_use_images = get_in_use_images(ctx).await;
ctx.logger.debug(format!("Found {} images in use", in_use_images.len()));
// Complete in_use field
images.iter_mut().for_each(|image| {
if in_use_images.contains(&image.reference) {
image.in_use = true
}
});
// Add extra images from references
if !all_references.is_empty() {
@@ -195,7 +204,10 @@ pub async fn get_updates(
}
// Await all the futures
let images = join_all(handles).await;
let mut updates: Vec<Update> = images.iter().map(|image| image.to_update()).collect();
let mut updates: Vec<Update> = images
.iter()
.map(|image| image.to_update())
.collect();
updates.extend_from_slice(&remote_updates);
updates
}