Add address capture deploy apply stage

This commit is contained in:
jwinterm
2026-07-07 05:56:47 -04:00
parent c3d44a5e5b
commit 8f4724089b
12 changed files with 256 additions and 30 deletions
+58
View File
@@ -8,6 +8,11 @@ import shutil
import shlex
import subprocess
from .addresses import (
AddressCaptureResult,
capture_address_results,
write_captured_address_results,
)
from .config import GatewayConfig
from .install_plan import (
InstallStateCopy,
@@ -70,6 +75,18 @@ class StartApplyResult:
message: str
@dataclass(frozen=True)
class AddressApplyResult:
site_id: str
protocol: str
status: str
mode: str
url: str
source: str
path: Path | None
message: str
CommandRunner = Callable[[tuple[str, ...]], CommandRunResult]
@@ -253,6 +270,17 @@ def apply_start(
return results
def apply_addresses(
config: GatewayConfig,
*,
dry_run: bool,
) -> list[AddressApplyResult]:
captures = capture_address_results(config)
if not dry_run:
write_captured_address_results(config, captures)
return [_address_result(result, dry_run=dry_run) for result in captures]
def _validate_state_copy(
config: GatewayConfig,
copy: InstallStateCopy,
@@ -452,6 +480,36 @@ def _validate_start_action(
)
def _address_result(
result: AddressCaptureResult,
*,
dry_run: bool,
) -> AddressApplyResult:
if result.status == "captured":
status = "planned" if dry_run else "written"
message = (
"would record captured public transport address"
if dry_run
else "recorded captured public transport address"
)
elif result.status == "missing":
status = "blocked"
message = result.message
else:
status = "skipped"
message = result.message
return AddressApplyResult(
site_id=result.site_id,
protocol=result.protocol,
status=status,
mode="dry-run" if dry_run else "live",
url=result.url,
source=result.source,
path=result.path,
message=message,
)
def _result(
copy: InstallStateCopy,
*,