From 907a61ce16354e1e70c4b84991a59f577d13c155 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Tue, 19 Dec 2023 11:04:48 +0100
Subject: [PATCH] [TASK] Ensure removing dangling images works with podman
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The TYPO3 core `runTests.sh` contains the `-u` option to
update the images and remove dangling images. Providing
an image name and a `--filter` option is not supported
by podman:
 > Error: cannot specify an image and a filter(s)
 and has not been discovered yet in the TYPO3
core implementation yet.

Both container runtimes `docker` and `podman` support filtering images
using the `reference` filter option. Therefore, this change modifies
the dangling image removal to use multiple filters

To verify that filtering with two `--filter` options can be used with
podman and docker, the following commands can be executed to list the
set of local non-dangling images.

Note: This example uses `dangling=false` instead of
	  `dangling=true` (as in `runTests.sh`), since we expect
      most developers don't have dangling images yet.

> podman images \
    --filter "reference=ghcr.io/typo3/core-testing-*" \
    --filter "dangling=false" --format "{{.ID}}"

> docker images \
    --filter "reference=ghcr.io/typo3/core-testing-*" \
    --filter "dangling=false" --format "{{.ID}}"

Resolves: #102697
Releases: main, 12.4, 11.5
Change-Id: I717d1aa229bdfb73c63aa5b2d46e1aff665544cb
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82236
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
---
 Build/Scripts/runTests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index 7de2ac69c5c5..66f4fe2a84de 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -980,7 +980,7 @@ case ${TEST_SUITE} in
         echo ""
         # remove "dangling" typo3/core-testing-* images (those tagged as <none>)
         echo "> remove \"dangling\" ghcr.io/typo3/core-testing-* images (those tagged as <none>)"
-        ${CONTAINER_BIN} images "ghcr.io/typo3/core-testing-*" --filter "dangling=true" --format "{{.ID}}" | xargs -I {} ${CONTAINER_BIN} rmi -f {}
+        ${CONTAINER_BIN} images --filter "reference=ghcr.io/typo3/core-testing-*" --filter "dangling=true" --format "{{.ID}}" | xargs -I {} ${CONTAINER_BIN} rmi -f {}
         echo ""
         ;;
     *)
-- 
GitLab