Files
computer-playbook/cli/deploy/development/exec.py
T
kevinveenbirkenbachandClaude Sonnet 4.6 3cfdc4bdf7 feat(services-disabler): propagate SERVICES_DISABLED through deploy stack and add conflict detection
Adds inventory consistency guard that fails fast when SERVICES_DISABLED
conflicts with an already-deployed inventory, and ensures the env var is
forwarded through the dedicated runner, development exec command, and
local test scripts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 19:36:16 +02:00

41 lines
1.2 KiB
Python

from __future__ import annotations
import argparse
import os
from .common import make_compose
def add_parser(sub: argparse._SubParsersAction) -> None:
p = sub.add_parser("exec", help="Execute a command inside the infinito container.")
p.add_argument(
"--distro",
default=os.environ.get("INFINITO_DISTRO", "arch"),
choices=["arch", "debian", "ubuntu", "fedora", "centos"],
help="Target distro (compose env INFINITO_DISTRO).",
)
p.add_argument(
"cmd",
nargs=argparse.REMAINDER,
help="Command to execute (use `--` to separate).",
)
p.set_defaults(_handler=handler)
def handler(args: argparse.Namespace) -> int:
compose = make_compose(distro=args.distro)
cmd = list(args.cmd or [])
if cmd and cmd[0] == "--":
cmd = cmd[1:]
if not cmd:
raise SystemExit("exec requires a command (e.g. exec -- sh -lc 'whoami')")
extra_env: dict[str, str] = {}
services_disabled = os.environ.get("SERVICES_DISABLED", "")
if services_disabled:
extra_env["SERVICES_DISABLED"] = services_disabled
r = compose.exec(cmd, check=False, extra_env=extra_env or None)
return int(r.returncode)