refactor(pipelock): move Docker-specific naming helpers to docker/pipelock.py
test / run tests/run_tests.py (pull_request) Successful in 16s
test / run tests/run_tests.py (pull_request) Successful in 16s
The three slug-based naming helpers were nominally on pipelock.py but each assumed a Docker container topology (the container name is 'claude-bottle-pipelock-<slug>', the proxy URL uses that container name). Move them next to DockerPipelockProxy: pipelock_container_name -> claude-bottle-pipelock-<slug> pipelock_proxy_url -> http://<container>:<port> pipelock_proxy_host_port -> <container>:<port> backend.py imports them directly from .pipelock; the orphan-cleanup test imports container_name from the same place.
This commit is contained in:
@@ -29,7 +29,11 @@ from . import util as docker_mod
|
||||
from .bottle import DockerBottle
|
||||
from .bottle_cleanup_plan import DockerBottleCleanupPlan
|
||||
from .bottle_plan import DockerBottlePlan
|
||||
from .pipelock import DockerPipelockProxy
|
||||
from .pipelock import (
|
||||
DockerPipelockProxy,
|
||||
pipelock_proxy_host_port,
|
||||
pipelock_proxy_url,
|
||||
)
|
||||
|
||||
|
||||
# Where the repo root lives, for `docker build` context. Computed once.
|
||||
@@ -204,7 +208,7 @@ class DockerBottleBackend(BottleBackend):
|
||||
"""Build the `docker run` argv and execute it, handling
|
||||
name-conflict races by incrementing the suffix (unless the name
|
||||
was user-pinned). Returns the resolved container name."""
|
||||
proxy_url = pipelock.pipelock_proxy_url(plan.slug)
|
||||
proxy_url = pipelock_proxy_url(plan.slug)
|
||||
docker_args: list[str] = [
|
||||
"--rm", "-d",
|
||||
"--name", plan.container_name,
|
||||
@@ -411,7 +415,7 @@ class DockerBottleBackend(BottleBackend):
|
||||
return
|
||||
|
||||
container = target
|
||||
proxy_host_port = pipelock.pipelock_proxy_host_port(plan.slug)
|
||||
proxy_host_port = pipelock_proxy_host_port(plan.slug)
|
||||
container_home = os.environ.get("CLAUDE_BOTTLE_CONTAINER_HOME", "/home/node")
|
||||
container_ssh = f"{container_home}/.ssh"
|
||||
agent_socket = "/run/claude-bottle-agent.sock"
|
||||
|
||||
@@ -12,10 +12,21 @@ from ...pipelock import (
|
||||
PIPELOCK_PORT,
|
||||
PipelockProxy,
|
||||
PipelockProxyPlan,
|
||||
pipelock_container_name,
|
||||
)
|
||||
|
||||
|
||||
def pipelock_container_name(slug: str) -> str:
|
||||
return f"claude-bottle-pipelock-{slug}"
|
||||
|
||||
|
||||
def pipelock_proxy_url(slug: str) -> str:
|
||||
return f"http://{pipelock_container_name(slug)}:{PIPELOCK_PORT}"
|
||||
|
||||
|
||||
def pipelock_proxy_host_port(slug: str) -> str:
|
||||
return f"{pipelock_container_name(slug)}:{PIPELOCK_PORT}"
|
||||
|
||||
|
||||
class DockerPipelockProxy(PipelockProxy):
|
||||
"""Brings the pipelock sidecar up and down via Docker."""
|
||||
|
||||
|
||||
@@ -42,18 +42,6 @@ DEFAULT_ALLOWLIST: tuple[str, ...] = (
|
||||
)
|
||||
|
||||
|
||||
def pipelock_container_name(slug: str) -> str:
|
||||
return f"claude-bottle-pipelock-{slug}"
|
||||
|
||||
|
||||
def pipelock_proxy_url(slug: str) -> str:
|
||||
return f"http://{pipelock_container_name(slug)}:{PIPELOCK_PORT}"
|
||||
|
||||
|
||||
def pipelock_proxy_host_port(slug: str) -> str:
|
||||
return f"{pipelock_container_name(slug)}:{PIPELOCK_PORT}"
|
||||
|
||||
|
||||
# --- Allowlist resolution --------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ from claude_bottle.backend.docker.network import (
|
||||
network_create_internal,
|
||||
network_remove,
|
||||
)
|
||||
from claude_bottle.backend.docker.pipelock import DockerPipelockProxy
|
||||
from claude_bottle.pipelock import pipelock_container_name
|
||||
from claude_bottle.backend.docker.pipelock import (
|
||||
DockerPipelockProxy,
|
||||
pipelock_container_name,
|
||||
)
|
||||
from tests._docker import skip_unless_docker
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user