Files
computer-playbook/scripts/tests/deploy/local/exec/container.sh
T
kevinveenbirkenbachandClaude Opus 4.7 9a578952c3 feat(env): SPOT env-pipeline + INFINITO_* namespace
Replace 8 bash env modules with a single Python generator
(cli.meta.env) that materialises env/static.env + runtime context
into a gitignored .env. Each variable lives in its own handler
under utils/env/handlers/; defaults carry inline one-line `# ...`
comments.

Rename to the INFINITO_* schema:
- workflow inputs: APPS, SERVICES_DISABLED, CMD, DEBUG, WHITELIST,
  BUNDLES, FULL_CYCLE, VARIANT, RUN_FLAGS, LIMIT_HOST, PARALLEL
- inventory: INVENTORY_DIR / INVENTORY_FILE / HOST_VARS_FILE,
  PW_FILE -> INVENTORY_PASSWORD_FILE
- venv: VENV_BASE / VENV_FALLBACK / VENV_NAME
- new SPOT defaults: COMPILE_SILENCE, CONTAINER_NO_CA,
  WAIT_HEALTH_TIMEOUT_S, PACKAGE_CACHE_FRONTEND_INIT_IMAGE,
  promoted IMAGE_TAG from GHA-only to general passthrough

compose.yml hardening:
- inline \${VAR:-default} removed; strict \${VAR:?...} everywhere
- new integration lint blocks regressions

Tooling:
- scripts/install/all.sh owns the stamp-file install logic
  (Makefile target delegates)
- scripts/meta/env/load.sh is the single shell entry point;
  8 bash modules deleted
- new shell lint: no INFINITO_* defaults outside env/static.env

Tests:
- 93 new unit tests for utils/env/{builder,parser,runtime,writer}
- restructure tests/lint into repository/ (file-content rules) vs
  filesystem/{shell,python,env}/ (filesystem-shape rules)
- drift + smoke integration tests against the generator

Docs:
- variables.md is now a pointer; per-variable docs live next to
  the key in env/static.env / env/ci.env
- compose.yml.md drops the Default column

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

81 lines
2.2 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 INFINITO_CMD or positional arguments are set.
#
# Usage:
# scripts/tests/deploy/local/exec/container.sh [command...] # nocheck: self-path-reference
#
# Environment:
# INFINITO_DISTRO arch|debian|ubuntu|fedora|centos
# INFINITO_CONTAINER Optional explicit container name
# INFINITO_CMD One-off shell command to run instead of an interactive shell
#
# Examples:
# scripts/tests/deploy/local/exec/container.sh whoami # nocheck: self-path-reference
# INFINITO_CMD='whoami && id' scripts/tests/deploy/local/exec/container.sh # nocheck: self-path-reference
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../../" && pwd)"
usage() {
cat <<EOF
Usage:
${0}
${0} [command...]
Environment:
INFINITO_DISTRO arch|debian|ubuntu|fedora|centos
INFINITO_CONTAINER Optional explicit container name
INFINITO_CMD One-off shell command to run instead of an interactive shell
Examples:
${0}
${0} whoami
INFINITO_CMD='whoami && id' ${0}
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
cd "${REPO_ROOT}"
if [[ -f "scripts/meta/env/load.sh" ]]; then
# shellcheck source=scripts/meta/env/load.sh
source "scripts/meta/env/load.sh"
else
echo "ERROR: missing scripts/meta/env/load.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/load.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 "${INFINITO_CMD:-}" ]]; then
exec docker exec "${docker_exec_flags[@]}" -w /opt/src/infinito "${container}" sh -lc "${INFINITO_CMD}"
fi
exec docker exec "${docker_exec_flags[@]}" -w /opt/src/infinito "${container}" sh