07c975636d
Rename the module files to match their functions' verb-first names: `bottle_provision.py` -> `provision_bottle.py`, `gateway_provision.py` -> `provision_gateway.py` (and the test file to match). Imports, docstrings, and the git_gate/service.py pointer updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""The `GatewayTransport` for the docker gateway container (PRD 0070).
|
|
|
|
How the launcher stages files + runs commands in the running gateway container:
|
|
`docker exec` / `docker cp` over the docker socket. The backend-neutral
|
|
provisioning logic that drives it lives in `backend.provision_gateway`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .util import run_docker
|
|
from ...gateway import GatewayProvisionError
|
|
|
|
|
|
class DockerGatewayTransport:
|
|
"""`GatewayTransport` for the docker gateway container (exec/cp)."""
|
|
|
|
def __init__(self, gateway: str) -> None:
|
|
self.gateway = gateway
|
|
|
|
def exec(self, argv: list[str]) -> None:
|
|
proc = run_docker(["docker", "exec", self.gateway, *argv])
|
|
if proc.returncode != 0:
|
|
raise GatewayProvisionError(
|
|
f"gateway exec {argv!r} failed: {proc.stderr.strip()}"
|
|
)
|
|
|
|
def cp_into(self, src: str, dest: str) -> None:
|
|
proc = run_docker(["docker", "cp", src, f"{self.gateway}:{dest}"])
|
|
if proc.returncode != 0:
|
|
raise GatewayProvisionError(
|
|
f"gateway cp {src} -> {dest} failed: {proc.stderr.strip()}"
|
|
)
|
|
|
|
|
|
__all__ = ["DockerGatewayTransport"]
|