Files
computer-playbook/utils/software.py
T
kevinveenbirkenbachandClaude Opus 5 c480c748ea fix(docs): name the image the run resolved instead of a frozen reference
The published Production block hardcoded ghcr.io/infinito-nexus/core/debian, which duplicates the template meta/distros.yml declares and points every reader at :latest. That index carries linux/amd64 and an attestation, so the docs CLI test, which executes the published instructions verbatim, died on arm64 with `no matching manifest for linux/arm64/v8`.

deploy_image() prefers INFINITO_IMAGE, which scripts/tests/deploy/ci/one.sh already exports from resolve/image/ci.sh, and otherwise composes the reference through environment_image() from the distro and tag default.env declares and the owner and repository SOFTWARE_REPOSITORY carries. The default is byte-identical to the literal it replaces.

Nothing versioned becomes environment-dependent: the Quick Setup block is never committed, and roles/web-app-docs rebuilds it inside the container, where builder.py puts the snapshot first on PYTHONPATH and passes os.environ through. CI therefore tests the instructions against the image the run just built rather than against a release from months ago.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-05 00:20:53 +02:00

41 lines
1.5 KiB
Python

"""The software's identity: its repository, read from the group_vars SPOT, its author and address."""
from __future__ import annotations
import os
from utils.cache.files import PROJECT_ROOT
from utils.cache.yaml import load_yaml
from utils.distros import environment_image
from utils.env.parser import parse_static_env
SOFTWARE_VARS = PROJECT_ROOT / "group_vars" / "all" / "00_general.yml"
SOFTWARE_NAME: str = load_yaml(str(SOFTWARE_VARS))["SOFTWARE_NAME"]
SOFTWARE_REPOSITORY: str = load_yaml(str(SOFTWARE_VARS))["SOFTWARE_REPOSITORY"]
SOFTWARE_AUTHOR = "Kevin Veen-Birkenbach"
SOFTWARE_EMAIL = "kevinveenbirkenbach@infinito.nexus"
SOFTWARE_URL = "https://infinito.nexus"
SOFTWARE_CONTACT = "contact@infinito.nexus"
SOFTWARE_LICENSE = "Infinito.Nexus Community License (Non-Commercial)"
DEPLOY_IMAGE_ENV = "INFINITO_IMAGE"
def deploy_image() -> str:
"""Reference of the image the published deploy instructions tell a reader to run.
Returns:
The ``INFINITO_IMAGE`` the run resolved for itself when set, otherwise
the environment image of the distro and tag ``default.env`` declares,
under the owner and repository of ``SOFTWARE_REPOSITORY``.
"""
if override := os.environ.get(DEPLOY_IMAGE_ENV):
return override
declared = parse_static_env(PROJECT_ROOT / "default.env")
owner, repository = SOFTWARE_REPOSITORY.removesuffix(".git").rsplit("/", 2)[-2:]
return environment_image(
declared["INFINITO_DISTRO"],
owner,
repository,
declared["INFINITO_IMAGE_TAG"],
)