libvirt/ci/list-images.sh
Andrea Bolognani 3e3cad5238 ci: Fetch list of available container images dynamically
Any static list of images is destined to become outdated eventually,
so let's start generating it dynamically instead.

Unfortunately there doesn't seem to be a straightforward way to get
Podman/Docker to list all repositories under quay.io/libvirt, so we
have to resort to searching and filtering manually; and since the
two tools behave slightly differently in that regard, it's more
sane to have the logic in a separate shell script than it would be
to keep it inline in the Makefile with all the annoying escaping
doing so would entail.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-06 16:43:46 +01:00

27 lines
772 B
Bash

#!/bin/sh
engine="$1"
prefix="$2"
do_podman() {
# Podman freaks out if the search term ends with a dash, which ours
# by default does, so let's strip it. The repository name is the
# second field in the output, and it already starts with the registry
podman search --limit 100 "${prefix%-}" | while read _ repo _; do
echo "$repo"
done
}
do_docker() {
# Docker doesn't include the registry name in the output, so we have
# to add it. The repository name is the first field in the output
registry="${prefix%%/*}"
docker search --limit 100 "$prefix" | while read repo _; do
echo "$registry/$repo"
done
}
"do_$engine" | grep "^$prefix" | sed "s,^$prefix,,g" | while read repo; do
echo " $repo"
done | sort -u