mirror of
https://github.com/Such-Software/adaptive-multi-protocol-gateway.git
synced 2026-10-17 07:31:32 +02:00
Add supervisor stage deploy apply
This commit is contained in:
+73
-1
@@ -5,6 +5,7 @@ from pathlib import Path
|
||||
import shlex
|
||||
|
||||
from .activation import activation_steps, apply_preflight
|
||||
from .apply import supervisor_target
|
||||
from .addresses import effective_address_records
|
||||
from .approvals import (
|
||||
ACTIVATION_ARTIFACT_KIND,
|
||||
@@ -22,7 +23,7 @@ from .install_plan import (
|
||||
install_supervisor_actions,
|
||||
)
|
||||
from .plan import plan_artifacts
|
||||
from .platforms import PlatformProvider
|
||||
from .platforms import PlatformProvider, detect_platform
|
||||
from .status import DaemonProbeFunc, doctor_gateway
|
||||
|
||||
|
||||
@@ -88,6 +89,12 @@ def deploy_plan(
|
||||
platform_provider=platform_provider,
|
||||
daemon_probe=daemon_probe,
|
||||
),
|
||||
_deploy_apply_step(
|
||||
config,
|
||||
command_context,
|
||||
platform_provider=platform_provider,
|
||||
daemon_probe=daemon_probe,
|
||||
),
|
||||
)
|
||||
status = _overall_status(steps)
|
||||
return DeployPlan(
|
||||
@@ -308,6 +315,71 @@ def _apply_preflight_step(
|
||||
)
|
||||
|
||||
|
||||
def _deploy_apply_step(
|
||||
config: GatewayConfig,
|
||||
commands: _CommandContext,
|
||||
*,
|
||||
platform_provider: PlatformProvider | None,
|
||||
daemon_probe: DaemonProbeFunc | None,
|
||||
) -> DeployStep:
|
||||
provider = platform_provider or detect_platform()
|
||||
state_copies = install_state_copies(
|
||||
config,
|
||||
platform_provider=provider,
|
||||
daemon_probe=daemon_probe,
|
||||
)
|
||||
supervisor_actions = install_supervisor_actions(
|
||||
config,
|
||||
platform_provider=provider,
|
||||
daemon_probe=daemon_probe,
|
||||
)
|
||||
review = [
|
||||
item
|
||||
for item in (*state_copies, *supervisor_actions)
|
||||
if item.status != "planned"
|
||||
]
|
||||
if review:
|
||||
return DeployStep(
|
||||
"deploy-apply",
|
||||
"review",
|
||||
commands.command("apply --dry-run", platform=True),
|
||||
f"review {len(review)} staged apply input(s)",
|
||||
)
|
||||
missing_state = [copy for copy in state_copies if not copy.target.exists()]
|
||||
if missing_state:
|
||||
return DeployStep(
|
||||
"deploy-apply",
|
||||
"todo",
|
||||
commands.command("deploy apply --stage state --dry-run", platform=True),
|
||||
f"copy {len(missing_state)} approved state artifact(s)",
|
||||
)
|
||||
missing_supervisors = [
|
||||
action
|
||||
for action in supervisor_actions
|
||||
if not supervisor_target(provider, action).exists()
|
||||
]
|
||||
if missing_supervisors:
|
||||
return DeployStep(
|
||||
"deploy-apply",
|
||||
"todo",
|
||||
commands.command("deploy apply --stage supervisor --dry-run", platform=True),
|
||||
f"install {len(missing_supervisors)} approved supervisor file(s)",
|
||||
)
|
||||
if state_copies or supervisor_actions:
|
||||
return DeployStep(
|
||||
"deploy-apply",
|
||||
"ready",
|
||||
commands.command("deploy apply --stage supervisor --dry-run", platform=True),
|
||||
"staged deploy files are applied",
|
||||
)
|
||||
return DeployStep(
|
||||
"deploy-apply",
|
||||
"ready",
|
||||
"-",
|
||||
"no managed deploy apply stages are needed",
|
||||
)
|
||||
|
||||
|
||||
def _approval_candidates(
|
||||
config: GatewayConfig,
|
||||
platform_provider: PlatformProvider | None,
|
||||
|
||||
Reference in New Issue
Block a user