From nobody Fri Dec 19 19:19:05 2025 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=1616083945; cv=none; d=zohomail.com; s=zohoarc; b=jzgqXGFTFiEzijop86cwyo1omYSLmxd162TajWtUXfxgxWeIkO3E5MyhHjyrq962nC0TUg58nhQ97nCvxZVmGnG6M+rm1nDlbOohAHLPDTPNX4Rzbn1MPgxcKBaShQZfSZBzmHuW6qJ9viU+W70uDY8Urwigt8h6EUQQFX5lQKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616083945; 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=zecwz5wqw9mdGjV/g/rTzPo5R5xyepQKqXOVYHFtNmY=; b=guLYAETsK7DaySzCZtL+9e6v3i1cAC1Wtkv6hMLnlQ3qXhlmyGYF8gMYTXJXfTMTCh7r+bMSkQ95hsj0+x9h9LEx5Jk97Tnvqlu1QsA//ndIIII2XPYvaT5uZuMyooq98/RYMg6Ts959HlF3Gj42YqoRvV3a4Bhy0omPvZ+ETLo= 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 1616083945526937.6714249670263; Thu, 18 Mar 2021 09:12:25 -0700 (PDT) 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-336-xmMq4vv_MDqdQHDLVVSuVw-1; Thu, 18 Mar 2021 12:12:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 446FB84BA4D; Thu, 18 Mar 2021 16:12:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B20119726; Thu, 18 Mar 2021 16:12:03 +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 B36E14A7CB; Thu, 18 Mar 2021 16:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IGBsN0024208 for ; Thu, 18 Mar 2021 12:11:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id E658E60938; Thu, 18 Mar 2021 16:11:54 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.192.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43AE66B8E5; Thu, 18 Mar 2021 16:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616083944; 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=zecwz5wqw9mdGjV/g/rTzPo5R5xyepQKqXOVYHFtNmY=; b=e90F5/8hwVN8V6VNSJkKyIQ/oLiBAel3+aLrT5EsssC6O10313s2wkuT/BhhOVr+fwyZTI JLbtFb6OKIS3T9ub9rB+wV79+knWJxbsB3gg3sv7h1WLQGj2M4wBM4PVAL0n6ALb66w9sR Gw3hb8ADgZKDIjxc0T8AZUrXo1KWNW0= X-MC-Unique: xmMq4vv_MDqdQHDLVVSuVw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH v4 4/6] ci: helper: Rewrite image listing to Python Date: Thu, 18 Mar 2021 17:11:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.84 on 10.5.11.23 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" The corresponding Bash script is dropped. After this patch's rewrite, the Makefile's original image listing target remains intact only to notify the user to use the Python helper instead. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- ci/Makefile | 12 ------------ ci/helper | 38 +++++++++++++++++++++++++++++++++++++- ci/list-images.sh | 14 -------------- 3 files changed, 37 insertions(+), 27 deletions(-) delete mode 100644 ci/list-images.sh diff --git a/ci/Makefile b/ci/Makefile index 72f5bda942..02ce0df7ee 100644 --- a/ci/Makefile +++ b/ci/Makefile @@ -211,17 +211,6 @@ ci-build@%: ci-test@%: $(MAKE) -C $(CI_ROOTDIR) ci-build@$* CI_NINJA_ARGS=3Dtest =20 -ci-list-images: - @echo - @echo "Available x86 container images:" - @echo - @sh list-images.sh "$(CI_IMAGE_PREFIX)" | grep -v cross - @echo - @echo "Available cross-compiler container images:" - @echo - @sh list-images.sh "$(CI_IMAGE_PREFIX)" | grep cross - @echo - ci-help: @echo @echo @@ -241,7 +230,6 @@ ci-help: @echo " ci-build@\$$IMAGE - run a default 'ninja' build" @echo " ci-test@\$$IMAGE - run a 'ninja test'" @echo " ci-shell@\$$IMAGE - run an interactive shell" - @echo " ci-list-images - list available images" @echo " ci-help - show this help message" @echo @echo "Available make variables:" diff --git a/ci/helper b/ci/helper index 53baef3cb1..31cf72fbdf 100755 --- a/ci/helper +++ b/ci/helper @@ -11,6 +11,8 @@ import shutil import subprocess import sys =20 +import util + =20 class Parser: def __init__(self): @@ -66,6 +68,20 @@ class Parser: help=3D"path to lcitool binary", ) =20 + # Options that are common to actions communicating with a GitLab + # instance + gitlabparser =3D argparse.ArgumentParser(add_help=3DFalse) + gitlabparser.add_argument( + "--namespace", + default=3D"libvirt/libvirt", + help=3D"GitLab project namespace" + ) + gitlabparser.add_argument( + "--gitlab-uri", + default=3D"https://gitlab.com", + help=3D"base GitLab URI" + ) + # Main parser self.parser =3D argparse.ArgumentParser() subparsers =3D self.parser.add_subparsers( @@ -105,6 +121,7 @@ class Parser: listimagesparser =3D subparsers.add_parser( "list-images", help=3D"list known container images", + parents=3D[gitlabparser], formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter, ) listimagesparser.set_defaults(func=3DApplication.action_list_image= s) @@ -249,7 +266,26 @@ class Application: self.make_run(f"ci-shell@{self.args.target}") =20 def action_list_images(self): - self.make_run(f"ci-list-images") + registry_uri =3D util.get_registry_uri(self.args.namespace, + self.args.gitlab_uri) + images =3D util.get_registry_images(registry_uri) + + # skip the "ci-" prefix each of our container images' name has + name_prefix =3D "ci-" + names =3D [i["name"][len(name_prefix):] for i in images] + names.sort() + + native =3D [name for name in names if "-cross-" not in name] + cross =3D [name for name in names if "-cross-" in name] + + spacing =3D 4 * " " + print("Available x86 container images:\n") + print(spacing + ("\n" + spacing).join(native)) + + if cross: + print() + print("Available cross-compiler container images:\n") + print(spacing + ("\n" + spacing).join(cross)) =20 def action_refresh(self): self.refresh_containers() diff --git a/ci/list-images.sh b/ci/list-images.sh deleted file mode 100644 index b85b132253..0000000000 --- a/ci/list-images.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -prefix=3D"${1##registry.gitlab.com/}" - -PROJECT_ID=3D192693 - -all_repos() { - curl -s "https://gitlab.com/api/v4/projects/$PROJECT_ID/registry/reposit= ories?per_page=3D100" \ - | tr , '\n' | grep '"path":' | sed 's,"path":",,g;s,"$,,g' -} - -all_repos | grep "^$prefix" | sed "s,^$prefix,,g" | while read repo; do - echo " $repo" -done | sort -u --=20 2.30.2