343f3a0735
`backend/docker/gateway_provision.py` had no docker-specific code left once `DockerGatewayTransport` moved out — `provision_git_gate` / `deprovision_git_gate` drive any `GatewayTransport`, and the guest-side paths they write (`/git-gate/creds/<id>`, `/git/<id>`, `/etc/git-gate/...`) are identical inside every backend's gateway. Yet the neutral `backend/consolidated_util.py` reached into the docker package to import them. Move it to `backend/gateway_provision.py`, a sibling of its only importer. The gateway *package* can't host it (git_gate already imports gateway.git_gate, so gateway importing git_gate would cycle), but the backend layer uses git_gate freely. Docstrings + the git_gate/service.py pointer updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""The `GatewayTransport` for the Apple gateway container (PRD 0070).
|
|
|
|
How the launcher stages files + runs commands in the running gateway container:
|
|
the `container` CLI's exec/cp equivalents. The backend-neutral provisioning
|
|
logic that drives it lives in `backend.gateway_provision`; Docker uses
|
|
`docker exec`/`docker cp` and Firecracker uses SSH.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from ...gateway import GatewayProvisionError
|
|
from . import util as container_mod
|
|
from .gateway import GATEWAY_NAME
|
|
|
|
|
|
class MacosGatewayTransport:
|
|
"""`GatewayTransport` for the gateway daemons in the Apple gateway container."""
|
|
|
|
def __init__(self, gateway: str = GATEWAY_NAME) -> None:
|
|
self.gateway = gateway
|
|
|
|
def exec(self, argv: list[str]) -> None:
|
|
result = container_mod.run_container_argv(
|
|
["container", "exec", self.gateway, *argv]
|
|
)
|
|
if result.returncode != 0:
|
|
raise GatewayProvisionError(
|
|
f"gateway exec {argv!r} failed: "
|
|
f"{(result.stderr or '').strip() or '<no stderr>'}"
|
|
)
|
|
|
|
def cp_into(self, src: str, dest: str) -> None:
|
|
result = container_mod.run_container_argv(
|
|
["container", "cp", src, f"{self.gateway}:{dest}"]
|
|
)
|
|
if result.returncode != 0:
|
|
raise GatewayProvisionError(
|
|
f"gateway cp {src} -> {dest} failed: "
|
|
f"{(result.stderr or '').strip() or '<no stderr>'}"
|
|
)
|
|
|
|
|
|
__all__ = ["MacosGatewayTransport"]
|