refactor(docker): split bottles/docker/__init__.py into sibling modules
test / run tests/run_tests.py (pull_request) Successful in 14s
test / run tests/run_tests.py (pull_request) Successful in 14s
The single docker/__init__.py grew to ~555 lines holding the platform, its plan classes, the bottle handle, and the runsc probe. Split into: - util.py : Docker subprocess primitives + runsc_available - bottle_plan.py : DockerBottlePlan (+ its print method) - bottle_cleanup_plan.py : DockerBottleCleanupPlan - bottle.py : _DockerBottle handle class - platform.py : DockerBottlePlatform (the bulk) docker/__init__.py becomes a thin re-export shim so existing imports (claude_bottle.bottles.docker.DockerBottlePlatform, etc.) keep working.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""DockerBottleCleanupPlan — concrete subclass of BottleCleanupPlan.
|
||||
|
||||
Holds the tuples of container and network names that
|
||||
DockerBottlePlatform.cleanup will remove. The y/N preflight reads
|
||||
these via `print`; the CLI short-circuits via `empty`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
from ...log import info
|
||||
from .. import BottleCleanupPlan
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DockerBottleCleanupPlan(BottleCleanupPlan):
|
||||
"""Resources DockerBottlePlatform.cleanup will remove. Produced by
|
||||
`prepare_cleanup` from a snapshot of `docker ps -a` + `docker
|
||||
network ls`; sorted so the y/N output is stable."""
|
||||
|
||||
containers: tuple[str, ...]
|
||||
networks: tuple[str, ...]
|
||||
|
||||
@property
|
||||
def empty(self) -> bool:
|
||||
return not self.containers and not self.networks
|
||||
|
||||
def print(self) -> None:
|
||||
print(file=sys.stderr)
|
||||
for name in self.containers:
|
||||
info(f"container: {name}")
|
||||
for name in self.networks:
|
||||
info(f"network: {name}")
|
||||
print(file=sys.stderr)
|
||||
Reference in New Issue
Block a user