From 6d4df20f54e48bb82537ea84ca6ce659556db331 Mon Sep 17 00:00:00 2001 From: Sergio <77530549+sergi0g@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:05:23 +0200 Subject: [PATCH] Ignore registries before retrieving auth tokens --- src/check.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/check.rs b/src/check.rs index fbcf321..ee3a39e 100644 --- a/src/check.rs +++ b/src/check.rs @@ -120,6 +120,16 @@ pub async fn get_updates( .iter() .map(|image| &image.parts.registry) .unique() + .filter(|®istry| match ctx.config.registries.get(registry) { + Some(config) => { + if config.ignore { + false + } else { + true + } + } + None => true, + }) .collect::>(); // Create request client. All network requests share the same client for better performance. @@ -138,7 +148,7 @@ pub async fn get_updates( // Retrieve an authentication token (if required) for each registry. let mut tokens: FxHashMap<&str, Option> = FxHashMap::default(); - for registry in registries { + for registry in registries.clone() { let credentials = if let Some(registry_config) = ctx.config.registries.get(registry) { ®istry_config.authentication } else { @@ -163,24 +173,11 @@ pub async fn get_updates( ctx.logger.debug(format!("Tokens: {:?}", tokens)); - let ignored_registries = ctx - .config - .registries - .iter() - .filter_map(|(registry, registry_config)| { - if registry_config.ignore { - Some(registry) - } else { - None - } - }) - .collect::>(); - let mut handles = Vec::with_capacity(images.len()); // Loop through images check for updates for image in &images { - let is_ignored = ignored_registries.contains(&&image.parts.registry) + let is_ignored = !registries.contains(&&image.parts.registry) || ctx .config .images