ci-test@%:
$(MAKE) -C $(CI_ROOTDIR) ci-build@$* CI_NINJA_ARGS=test
-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
@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:"
import subprocess
import sys
+import util
+
class Parser:
def __init__(self):
help="path to lcitool binary",
)
+ # Options that are common to actions communicating with a GitLab
+ # instance
+ gitlabparser = argparse.ArgumentParser(add_help=False)
+ gitlabparser.add_argument(
+ "--namespace",
+ default="libvirt/libvirt",
+ help="GitLab project namespace"
+ )
+ gitlabparser.add_argument(
+ "--gitlab-uri",
+ default="https://gitlab.com",
+ help="base GitLab URI"
+ )
+
# Main parser
self.parser = argparse.ArgumentParser()
subparsers = self.parser.add_subparsers(
listimagesparser = subparsers.add_parser(
"list-images",
help="list known container images",
+ parents=[gitlabparser],
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
listimagesparser.set_defaults(func=Application.action_list_images)
self.make_run(f"ci-shell@{self.args.target}")
def action_list_images(self):
- self.make_run(f"ci-list-images")
+ registry_uri = util.get_registry_uri(self.args.namespace,
+ self.args.gitlab_uri)
+ images = util.get_registry_images(registry_uri)
+
+ # skip the "ci-" prefix each of our container images' name has
+ name_prefix = "ci-"
+ names = [i["name"][len(name_prefix):] for i in images]
+ names.sort()
+
+ native = [name for name in names if "-cross-" not in name]
+ cross = [name for name in names if "-cross-" in name]
+
+ spacing = 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))
def action_refresh(self):
self.refresh_containers()
+++ /dev/null
-#!/bin/sh
-
-prefix="${1##registry.gitlab.com/}"
-
-PROJECT_ID=192693
-
-all_repos() {
- curl -s "https://gitlab.com/api/v4/projects/$PROJECT_ID/registry/repositories?per_page=100" \
- | 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