Files
computer-playbook/utils/env/handlers
kevinveenbirkenbachandClaude Opus 4.7 183f41845b refactor(env): SPOT pkgmgr base image via handler, drop slim variant
default.env decomposed into INFINITO_PARENT_IMAGE_{OWNER,TAG,VARIANT}
atoms. New utils/env/handlers/infinito_parent_image.py owns the URL
composition `ghcr.io/{owner}/pkgmgr-{distro}:{tag}` as the single
definition site; scripts/image/{push,build}.sh consume the handler-
emitted INFINITO_PARENT_IMAGE from .env instead of inlining their own
format string.

Side effect: `compose up --build` now picks the parent image that
matches INFINITO_DISTRO. Previously default.env's hardcoded
pkgmgr-arch:stable won regardless, so debian-named containers were
silently built FROM the arch base. scripts/image/build.sh already
overrode per-distro, so its behavior is unchanged.

Other cleanups landed in the same pass:
- Slim variant removed end-to-end (Dockerfile stage, --variant CLI
  flag, slim suffix logic). Zero in-repo callers used it.
- compose.yml build-args INFINITO_PARENT_IMAGE / INFINITO_SRC_DIR now
  carry the same `:?Run 'make dotenv'…` guard as the runtime entries,
  so a missing .env fails fast with a clear message instead of with
  buildkit's `base name should not be blank`.

Note: fork-CI (pull_request_target trusted-helpers path) will stay red
until main's scripts/image/push.sh and scripts/meta/wait/images.sh
adopt the INFINITO_* names too — that is the deliberate cost of
keeping a single SPOT instead of carrying a bridge alias.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:44:50 +02:00
..

utils/env/handlers 🧩

Per-variable mapping logic for the .env generator. For the package's overall role see README.md. For general README conventions see documentation.md.

Purpose 🎯

Each module in this directory owns exactly one variable, or one tightly-coupled group resolved by a single helper call. The orchestrator in builder.py iterates the registry in __init__.py and calls each handler's apply(eb, ctx) in order.

File Naming 🏷️

  • A handler module name MUST match the lowercase of the variable it owns:
    • INFINITO_CONTAINER -> infinito_container.py
    • INFINITO_GHCR_MIRROR_PREFIX -> infinito_ghcr_mirror_prefix.py
  • The infinito_ prefix in the filename MUST be present iff the owned key carries the INFINITO_ prefix.
  • Aggregate handlers (one helper call resolves several keys at once) MUST take the singular topic name without a key suffix. Example: infinito_inventory.py resolves INFINITO_INVENTORY_DIR, INFINITO_INVENTORY_FILE, and INFINITO_INVENTORY_HOST_VARS_FILE from one scripts/inventory/resolve.sh invocation.
  • The trivial static passthroughs live in two collector files: passthrough.py (always emitted) and gha_passthrough.py (emitted only when ctx.on_gha is true).

Module Shape 📐

Every handler module MUST expose the same surface so the registry can call it uniformly:

"""<one-line docstring: what variable, what it derives from>."""

from __future__ import annotations
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from utils.env.builder import BuildContext, EnvBuilder

KEY = "INFINITO_..."
COMMENT = "<single-line per-key comment, mirrors default.env style>"


def apply(eb: EnvBuilder, ctx: BuildContext) -> None:
    ...
  • KEY MUST be the owned variable's name.
  • COMMENT MUST be a single line, no em dashes, that ends up above the key in the generated .env.
  • apply MUST take (eb, ctx) and return None.
  • A handler that targets a conditional branch (GHA-only, NIX-only, ...) MUST self-check the relevant ctx flag and return early. The registry calls every handler unconditionally.

Import Rules 🔗

  • A handler MUST NOT import another handler. Cross-handler data flows through eb.get(...) / eb.set(...) only.
  • A handler MAY import from parser.py, runtime.py, and stdlib.
  • A handler MUST NOT import from writer.py or builder.py at runtime. The EnvBuilder and BuildContext types MAY be referenced under TYPE_CHECKING for annotations only.

Registry 📋

  • __init__.py MUST list every handler module in ORDERED_HANDLERS.
  • The order in ORDERED_HANDLERS MUST respect data dependencies. Example: infinito_container runs after passthrough so it can read the resolved INFINITO_DISTRO.
  • Adding a handler MUST also bump the relevant baseline test in test_dotenv_generator.py when the new key is a static-default in default.env, so the drift test stays honest.