From nobody Mon Feb 9 03:52:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612977898; cv=none; d=zohomail.com; s=zohoarc; b=V0IvPHv2Zog5DimsJSk0aYQM+s9TJLLzYuw31P4lmytbqDEhCbLPE0wSb/2V+hdsrfGEC/Kc5PYhy5SoffdaSAr537RgEtIY3Gw0Tp1HdUbHojJgYtWludl+owAy2hAvTACstAmSv/UuZpZ6OGBQS2gW2rTiQdWeHUtzq2XWK+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612977898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7u97paZIKAqBfYFHaqqL4wmfT6iUw+mbkZJpNwhGrH0=; b=aIYD6BVMsWeAw+oF/Nul9Ys9GurIvjqZBYzJguSJucP+6wYEaoX3dcPz35pQ5M58ir+hqgtGFYXRtZrKZM5QpMKW6N6mvVgCUKyHa3mOdCFPw6cXucqxPb6c10sitJ8N3XSgxWBRlQJh+mqvQerOOwsJglKmZxzlTL/CfOrUbKc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612977897934639.0702398302514; Wed, 10 Feb 2021 09:24:57 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-BmXTMLyGN_avBenMFULVGg-1; Wed, 10 Feb 2021 12:24:54 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0487100CCC6; Wed, 10 Feb 2021 17:24:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AC901876A; Wed, 10 Feb 2021 17:24:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2CAD918095CD; Wed, 10 Feb 2021 17:24:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11AHOjJZ019444 for ; Wed, 10 Feb 2021 12:24:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BA025D9E8; Wed, 10 Feb 2021 17:24:45 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.192.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 864BB5D9DC; Wed, 10 Feb 2021 17:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612977896; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7u97paZIKAqBfYFHaqqL4wmfT6iUw+mbkZJpNwhGrH0=; b=OCn2E7IZvGUlKZyh+HCGIk76pejxOtbpZ6HK3dKh0z/cAnHy/sSvn/QNtsNw/QHYTvoYml 50lo1qknmBPi0oFUh1NRc1ud8n0dSBbzhMPbnE70OPGlZnSCavIfhNgsJKCP/MbH4wl7dG OM57I4kKTIvH/oRs5CDTQNmViCDThPU= X-MC-Unique: BmXTMLyGN_avBenMFULVGg-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] ci: list-images: Split some generic logic to a util module Date: Wed, 10 Feb 2021 18:24:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Parts of the code can be reused by another registry checker script introduced in the next patch. Signed-off-by: Erik Skultety --- ci/containers/util.py | 25 +++++++++++++++++++++++++ ci/list-images.py | 43 +++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 ci/containers/util.py diff --git a/ci/containers/util.py b/ci/containers/util.py new file mode 100644 index 0000000000..1ce326bba2 --- /dev/null +++ b/ci/containers/util.py @@ -0,0 +1,25 @@ +import json +import urllib.request as urllib + + +PROJECT_ID =3D 192693 + + +def get_registry_uri(project_id, + base_uri=3D"https://gitlab.com", + api_version=3D4): + uri =3D f"{base_uri}/api/v{str(api_version)}/projects/{project_id}/reg= istry/repositories" + return uri + + +def list_images(uri): + """ + Returns all container images as currently available for the given GitL= ab + project. + + ret: list of container image names + """ + r =3D urllib.urlopen(uri) + + # read the HTTP response and load the JSON part of it + return json.loads(r.read().decode()) diff --git a/ci/list-images.py b/ci/list-images.py index 6862ac347f..1a1d87c10b 100644 --- a/ci/list-images.py +++ b/ci/list-images.py @@ -1,29 +1,32 @@ #!/usr/bin/env python3 =20 -import json -import urllib.request as urllib +import containers.util as util =20 -PROJECT_ID =3D 192693 -DOMAIN =3D "https://gitlab.com" -API =3D "api/v4" =20 -uri =3D f"{DOMAIN}/{API}/projects/{PROJECT_ID}/registry/repositories" -r =3D urllib.urlopen(uri + "?per_page=3D100") +def list_image_names(uri): + images =3D util.list_images(uri) =20 -# read the HTTP response and load the JSON part of it -data =3D json.loads(r.read().decode()) + # skip the "ci-" prefix each of our container images' name has + names =3D [i["name"][3:] for i in images] + names.sort() =20 -# skip the "ci-" prefix each of our container images' name has -names =3D [i["name"][3:] for i in data] -names.sort() + return names =20 -names_native =3D [name for name in names if "cross" not in name] -names_cross =3D [name for name in names if "cross" in name] =20 -print("Available x86 container images:\n") -print("\t" + "\n\t".join(names_native)) +def main(): + names =3D list_image_names(util.get_registry_uri(util.PROJECT_ID) + "?= per_page=3D100") =20 -if names_cross: - print() - print("Available cross-compiler container images:\n") - print("\t" + "\n\t".join(names_cross)) + names_native =3D [name for name in names if "cross" not in name] + names_cross =3D [name for name in names if "cross" in name] + + print("Available x86 container images:\n") + print("\t" + "\n\t".join(names_native)) + + if names_cross: + print() + print("Available cross-compiler container images:\n") + print("\t" + "\n\t".join(names_cross)) + + +if __name__ =3D=3D "__main__": + main() --=20 2.29.2