From c754083cec21dac986bca382fe7cbf6eb26e52a6 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 17 Jul 2025 00:13:38 +0200 Subject: [PATCH] Added more detailled info to is_image_whitelisted --- backup-docker-to-local.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backup-docker-to-local.py b/backup-docker-to-local.py index a0bfa9e..bec6443 100644 --- a/backup-docker-to-local.py +++ b/backup-docker-to-local.py @@ -222,8 +222,20 @@ def change_containers_status(containers, status): print(f"No containers to {status}.") def is_image_whitelisted(container, images): + """ + Return True if the container's image matches any of the whitelist patterns. + Also prints out the image name and the match result. + """ + # fetch the image (e.g. "nextcloud:23-fpm-alpine") info = get_image_info(container)[0] - return any(img in info for img in images) + + # check against each pattern + whitelisted = any(pattern in info for pattern in images) + + # log the result + print(f"Container {container!r} → image {info!r} → whitelisted? {whitelisted}") + + return whitelisted def is_container_stop_required(containers): """