mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
Follow-up to d002796a5. The formula `infinito_nexus_${INFINITO_DISTRO}` is
now defined in exactly one place — `scripts/meta/env/defaults.sh:18`,
exported outside the load-once guard so it tracks INFINITO_DISTRO across
matrix iterations (caller re-sources defaults.sh after distro changes).
Every other site reads INFINITO_CONTAINER strictly from env; nothing
re-derives the formula, no lazy/colon-dash fallbacks, no per-call defaults.
Production code aligned:
- cli/deploy/development/common.py: add resolve_container() (strict env
reader, raises SystemExit on unset). make_compose() calls it as an
early-fail guard so a missing defaults.sh source surfaces here instead
of as a confusing compose.yml interpolation error later.
- cli/deploy/development/deploy.py: stop re-deriving from compose.distro;
use resolve_container().
- compose.yml: container_name reads ${INFINITO_CONTAINER:?...} strictly,
so callers that bypass defaults.sh fail fast with a clear hint.
- scripts/meta/resolve/image/local.sh: drop ${INFINITO_DISTRO:-debian}
fallback; require INFINITO_DISTRO via :? error.
- scripts/tests/deploy/ci/dedicated.sh: drop local _container fallback.
- scripts/tests/deploy/local/deploy/fresh-kept-app.sh: drop redundant
${INFINITO_DISTRO:-debian} reassignment after sourcing env/all.sh
(defaults.sh already defaults the value).
- scripts/tests/deploy/local/deploy/fresh-purged-app.sh: drop
target_container fallback; INFINITO_CONTAINER is already in env.
- scripts/tests/deploy/local/exec/container.sh: drop the lazy
${INFINITO_CONTAINER:=infinito_nexus_...} default; defaults.sh source
in env/all.sh already guarantees the value.
- scripts/tests/dns.sh: source defaults.sh so callers only need to set
INFINITO_DISTRO (the implicit dependency was previously a footgun).
- scripts/system/tls/trust/{wsl2,linux}.sh: same — source defaults.sh,
drop the ${INFINITO_CONTAINER:-infinito_nexus_debian} fallback in
linux.sh.
- .github/workflows/test-dns.yml: drop redundant
INFINITO_CONTAINER: infinito_nexus_${{ matrix.distro }} from per-step
env blocks (3 sites). The env now flows from INFINITO_DISTRO via the
defaults.sh sourced inside the scripts.
- tests/unit/cli/deploy/development/test_matrix_deploy.py: replace the
module-level os.environ.setdefault('INFINITO_CONTAINER', 'infinito_nexus_arch')
shim — which itself encoded the formula — with a module-level patch of
resolve_container that returns an opaque test-fixture string. Drop the
now-unused distro="arch" field from the _args() Namespace fixture
(deploy.handler stopped consuming it after the --distro arg removal).
Documentation aligned:
- docs/contributing/environment/variables.md: rewrite the INFINITO_CONTAINER
row to spell out the SPOT contract — set automatically by defaults.sh,
never re-derived elsewhere, callers re-source defaults.sh after
changing INFINITO_DISTRO mid-process.
- docs/contributing/artefact/files/compose.yml.md: replace the
INFINITO_DISTRO row (which described the now-removed
`infinito_nexus_${INFINITO_DISTRO:-debian}` interpolation) with an
INFINITO_CONTAINER row noting the strict ${INFINITO_CONTAINER:?...} read.
Verified:
- Formula derivation: 1 production hit (the SPOT in defaults.sh:18).
- INFINITO_CONTAINER fallback patterns (:-/:=): 0.
- --distro CLI arg refs: 0 (one comment explaining the removal).
- make test green: 1553 unit + 168 integration tests, no skipped suites.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
2.4 KiB
Bash
Executable File
83 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Open an interactive shell in the running infinito container, or execute a
|
|
# one-off command inside it when CMD or positional arguments are set.
|
|
#
|
|
# Usage:
|
|
# scripts/tests/deploy/local/exec/container.sh
|
|
# scripts/tests/deploy/local/exec/container.sh [command...]
|
|
#
|
|
# Environment:
|
|
# INFINITO_DISTRO arch|debian|ubuntu|fedora|centos
|
|
# INFINITO_CONTAINER Optional explicit container name
|
|
# CMD One-off shell command to run instead of an interactive shell
|
|
#
|
|
# Examples:
|
|
# scripts/tests/deploy/local/exec/container.sh
|
|
# scripts/tests/deploy/local/exec/container.sh whoami
|
|
# CMD='whoami && id' scripts/tests/deploy/local/exec/container.sh
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../../" && pwd)"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
scripts/tests/deploy/local/exec/container.sh
|
|
scripts/tests/deploy/local/exec/container.sh [command...]
|
|
|
|
Environment:
|
|
INFINITO_DISTRO arch|debian|ubuntu|fedora|centos
|
|
INFINITO_CONTAINER Optional explicit container name
|
|
CMD One-off shell command to run instead of an interactive shell
|
|
|
|
Examples:
|
|
scripts/tests/deploy/local/exec/container.sh
|
|
scripts/tests/deploy/local/exec/container.sh whoami
|
|
CMD='whoami && id' scripts/tests/deploy/local/exec/container.sh
|
|
EOF
|
|
}
|
|
|
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
if [[ -f "scripts/meta/env/all.sh" ]]; then
|
|
# shellcheck source=scripts/meta/env/all.sh
|
|
source "scripts/meta/env/all.sh"
|
|
else
|
|
echo "ERROR: missing scripts/meta/env/all.sh" >&2
|
|
exit 2
|
|
fi
|
|
|
|
# defaults.sh exports INFINITO_CONTAINER from INFINITO_DISTRO (single SPOT
|
|
# for the formula). Read strictly here — no local re-derivation.
|
|
: "${INFINITO_CONTAINER:?INFINITO_CONTAINER not set after sourcing scripts/meta/env/all.sh — bug in defaults.sh?}"
|
|
container="${INFINITO_CONTAINER}"
|
|
|
|
docker_exec_flags=(-i)
|
|
if [[ -t 0 && -t 1 ]]; then
|
|
docker_exec_flags=(-it)
|
|
fi
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
if [[ "${1:-}" == "--" ]]; then
|
|
shift
|
|
fi
|
|
if [[ $# -eq 0 ]]; then
|
|
usage
|
|
exit 2
|
|
fi
|
|
exec docker exec "${docker_exec_flags[@]}" -w /opt/src/infinito "${container}" "$@"
|
|
fi
|
|
|
|
if [[ -n "${CMD:-}" ]]; then
|
|
exec docker exec "${docker_exec_flags[@]}" -w /opt/src/infinito "${container}" sh -lc "${CMD}"
|
|
fi
|
|
|
|
exec docker exec "${docker_exec_flags[@]}" -w /opt/src/infinito "${container}" sh
|