Added more detailled info to is_image_whitelisted

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-17 00:13:38 +02:00
parent 84d0fd6346
commit c754083cec
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E

View File

@ -222,8 +222,20 @@ def change_containers_status(containers, status):
print(f"No containers to {status}.") print(f"No containers to {status}.")
def is_image_whitelisted(container, images): 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] 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): def is_container_stop_required(containers):
""" """