[libvirt PATCH 05/11] ci: util: Add new get_registry_images() function

Andrea Bolognani abologna at redhat.com
Fri Apr 23 15:03:02 UTC 2021


Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 ci/util.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/ci/util.py b/ci/util.py
index b6a99ce9c0..b314ebd078 100644
--- a/ci/util.py
+++ b/ci/util.py
@@ -72,6 +72,34 @@ def get_image_info(image_name: str) -> Dict[str, str]:
     return {"distro": distro, "cross": cross}
 
 
+def get_registry_images(registry_uri: str) -> Dict[str, List[str]]:
+    """
+    List all container images that are currently available in the
+    given GitLab project.
+
+    The returned dictionary contains an entry for each available
+    distro, with its associated value being a (possibly empty) list
+    of cross-building architectures it supports.
+
+    :param uri: URI pointing to a GitLab instance's image registry
+    :return: information about container images
+    """
+
+    registry_images = get_registry_images_raw(registry_uri)
+
+    # Parse the names of all images found on the registry and
+    # organize them by distro
+    images = {}
+    for image in registry_images:
+        info = get_image_info(image["name"])
+        if info["distro"] not in images:
+            images[info["distro"]] = []
+        if info["cross"]:
+            images[info["distro"]].append(info["cross"])
+
+    return images
+
+
 def get_registry_stale_images(registry_uri: str,
                               supported_distros: List[str]) -> Dict[str, int]:
     """
-- 
2.26.3




More information about the libvir-list mailing list