Files
computer-playbook/cli/meta/ci/image_ref.py
kevinveenbirkenbachandClaude Opus 5 ebd7d2e72b refactor(meta): centralize category/distro SPOTs
categories.yml moves from roles/ to the repository-root meta/, joining packages.yml. utils/roles/categories.py owns its location plus the tree-walking helpers that were stranded in entity/name.py, so no caller spells the path or duplicates the lookup.

meta/distros.yml becomes the SPOT for every distribution: os_family, Galaxy platform name, dev-environment base image, and the pkgmgr/pkgmgr-virgin/environment reference templates. It replaces seven scattered copies (DISTRO_FAMILY, VALID_DISTROS, _DISTROS, _CANONICAL_PLATFORMS, two shell arrays, a Makefile literal). INFINITO_DISTROS is no longer a static default but generated by utils/env/handlers/infinito/distros.py; the shell consumers read it through the env layer.

Drops dead CLI surface found along the way: --categories-file and --roles-dir on the provision CLI plus three unused parameters of generate_dynamic_inventory, and the positional roles_file of the invokable categories command.

tests/lint/repository/test_distros_spot.py pins the copies that cannot call the SPOT (workflow literals, docs table) and forbids composing a pkgmgr reference outside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 16:15:56 +02:00

60 lines
1.6 KiB
Python

"""Render a distro image reference from the ``meta/distros.yml`` SPOT.
Exists so shell and workflow steps can compose the same reference the env
layer composes, instead of spelling ``ghcr.io/...`` out a second time.
python3 -m cli.meta.ci.image_ref --kind environment \\
--distro debian --owner acme --repository infinito-nexus --tag ci-abc
"""
from __future__ import annotations
import argparse
import sys
from utils.distros import (
IMAGE_ENVIRONMENT,
IMAGE_PKGMGR,
environment_image,
pkgmgr_image,
)
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--kind",
required=True,
choices=(IMAGE_PKGMGR, IMAGE_ENVIRONMENT),
help="Which image reference to render.",
)
parser.add_argument("--distro", required=True, help="Distro id, e.g. debian.")
parser.add_argument("--owner", required=True, help="Registry owner.")
parser.add_argument("--tag", required=True, help="Image tag.")
parser.add_argument(
"--repository",
default="",
help="Repository name; required for --kind environment.",
)
args = parser.parse_args(argv)
if args.kind == IMAGE_PKGMGR:
print(pkgmgr_image(args.distro, owner=args.owner, tag=args.tag))
return 0
if not args.repository:
parser.error("--repository is required for --kind environment")
print(
environment_image(
args.distro,
owner=args.owner,
repository=args.repository,
tag=args.tag,
)
)
return 0
if __name__ == "__main__":
sys.exit(main())