|
105 | 105 | DecisionStatus, |
106 | 106 | DecisionStore, |
107 | 107 | ProposalRequest, |
| 108 | + Requirement, |
108 | 109 | Targets, |
109 | 110 | approve, |
110 | 111 | propose, |
@@ -1947,12 +1948,17 @@ class ApproveDecisionArgs(DecisionsArgs): |
1947 | 1948 |
|
1948 | 1949 | @dataclass(frozen=True, slots=True) |
1949 | 1950 | class Decided: |
1950 | | - """One decision record, and what to do next when it waits for approval.""" |
| 1951 | + """One decision record, and what to do next when it waits for approval. |
| 1952 | +
|
| 1953 | + A read operation has run by the time it is recorded, so its play output |
| 1954 | + comes back with the record; it is the hosts' text, never trusted. |
| 1955 | + """ |
1951 | 1956 |
|
1952 | 1957 | effect: str |
1953 | 1958 | status: str |
1954 | 1959 | decision: dict[str, object] = Out(ordered=True) |
1955 | 1960 | next: list[str] = Out(ordered=True) |
| 1961 | + output: str | None = Out(default=None, external=True) |
1956 | 1962 |
|
1957 | 1963 |
|
1958 | 1964 | def _decision_failed(error: DecisionError) -> Exception: |
@@ -2003,8 +2009,17 @@ def operations_propose(args: ProposeArgs, ctx: Ctx) -> Decided: |
2003 | 2009 | decision = propose(request, store, run=_check_runner(ctx, args.root)) |
2004 | 2010 | except DecisionError as error: |
2005 | 2011 | raise _decision_failed(error) from error |
| 2012 | + output = ( |
| 2013 | + (args.root / decision.check.diff.path).read_text(encoding="utf-8") |
| 2014 | + if decision.requirement is Requirement.RUNS_FREELY |
| 2015 | + else None |
| 2016 | + ) |
2006 | 2017 | decided = Decided( |
2007 | | - effect="created", status="ok", decision=decision.as_document(), next=[] |
| 2018 | + effect="created", |
| 2019 | + status="ok", |
| 2020 | + decision=decision.as_document(), |
| 2021 | + next=[], |
| 2022 | + output=output, |
2008 | 2023 | ) |
2009 | 2024 | if decision.check.exit_code != 0: |
2010 | 2025 | message = ( |
@@ -3462,6 +3477,8 @@ def propose_operation(arguments: Mapping[str, object], ctx: Ctx) -> Decided: |
3462 | 3477 | ), |
3463 | 3478 | ctx, |
3464 | 3479 | ) |
| 3480 | + if operation.risk is RiskLevel.READ: |
| 3481 | + return decided |
3465 | 3482 | record = cast("Mapping[str, Mapping[str, object]]", decided.decision) |
3466 | 3483 | approve = f"{APPROVAL_COMMAND} {record['metadata']['id']} --yes" |
3467 | 3484 | return dataclasses.replace(decided, next=[approve]) |
|
0 commit comments