Run a whole project: project runs in manual and auto-confirm mode (RBT-WP-0008-T10)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: sonnet Assistant-Process: 295952@bnt-lap001 Assistant-Session: e93f64ad-516c-46eb-9666-aad8d300c477
This commit is contained in:
parent
1d1087fa7f
commit
eff75a303c
14 changed files with 1112 additions and 15 deletions
|
|
@ -69,8 +69,12 @@ def validate(reg: Registry, doc: Doc) -> list[str]:
|
|||
# ---- attribute resolution --------------------------------------------------------------------------
|
||||
|
||||
def _member(d: dict, pack_id: str, target: str | None = None) -> dict:
|
||||
"""The member for this runbook and target; a member without a target matches target=None."""
|
||||
for m in d["runbooks"]:
|
||||
if m["pack"] == pack_id and (target is None or m.get("target") == target):
|
||||
if m["pack"] == pack_id and m.get("target") == target:
|
||||
return m
|
||||
for m in d["runbooks"]: # lenient: a runbook named without its target
|
||||
if m["pack"] == pack_id and target is None:
|
||||
return m
|
||||
raise KeyError(pack_id)
|
||||
|
||||
|
|
@ -189,8 +193,12 @@ def state(reg: Registry, doc: Doc) -> dict:
|
|||
|
||||
# ---- runs from a project ------------------------------------------------------------------------------------
|
||||
|
||||
def start_run(reg: Registry, doc: Doc, pack_id: str, operator: str, target: str | None = None, mode: str = "manual"):
|
||||
"""Create a run of a member runbook with the project's attributes as defaults and the project as context."""
|
||||
def start_run(reg: Registry, doc: Doc, pack_id: str, operator: str, target: str | None = None, mode: str = "manual",
|
||||
values: dict | None = None, extra_context: dict | None = None):
|
||||
"""Create a run of a member runbook with the project's attributes as defaults and the project as context.
|
||||
|
||||
`values` replaces the current attributes (a project run passes the snapshot it took at its start);
|
||||
`extra_context` adds to the run's context (for example the project run it belongs to)."""
|
||||
d = doc.data
|
||||
if d["spec"] != "project/v0.1":
|
||||
raise R.RunError("a template is not run; instantiate it into a project first")
|
||||
|
|
@ -199,8 +207,8 @@ def start_run(reg: Registry, doc: Doc, pack_id: str, operator: str, target: str
|
|||
raise R.RunError(f"project {doc.id} is invalid: {errs[0]}")
|
||||
member = _member(d, pack_id, target)
|
||||
pack = reg.packs[pack_id]
|
||||
ctx = {"project": doc.id, "environment": d["environment"], "target": member.get("target")}
|
||||
values = member_values(reg, d, member)
|
||||
ctx = {"project": doc.id, "environment": d["environment"], "target": member.get("target"), **(extra_context or {})}
|
||||
values = dict(values) if values is not None else member_values(reg, d, member)
|
||||
if pack.spec == "runbook-pack/v0.2":
|
||||
from . import run2
|
||||
return run2.create(pack, operator, values, mode=mode, context=ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue