Account for deferred retirements in apply budget

This commit is contained in:
Lyncoln
2026-09-20 13:13:28 -04:00
parent a93e067bfd
commit 572dd9eae4
4 changed files with 112 additions and 10 deletions
+14 -3
View File
@@ -65,7 +65,7 @@ def build_parser():
"--max-changes",
type=_nonnegative_int,
default=None,
help="Maximum CREATE/UPDATE actions allowed with --apply",
help="Maximum planned mutations allowed with --apply",
)
sub.add_parser("plugins", help="Show the configured source/provider plugins")
@@ -202,11 +202,21 @@ def run_reconcile(args):
for action in plan.actions
)
retirement_count = sum(
len(plan.retirements)
for plan in result.plans
)
mutation_count = (
change_count
+ retirement_count
)
print()
print(
"Plan summary: "
f"{create_count} create, "
f"{update_count} update, "
f"{retirement_count} retirement, "
f"{noop_count} unchanged"
)
@@ -221,10 +231,10 @@ def run_reconcile(args):
if (
args.max_changes is not None
and change_count > args.max_changes
and mutation_count > args.max_changes
):
raise RuntimeError(
f"Refusing to apply {change_count} change(s); "
f"Refusing to apply {mutation_count} mutation(s); "
f"--max-changes allows {args.max_changes}"
)
@@ -241,6 +251,7 @@ def run_reconcile(args):
print(
"APPLY COMPLETE: "
f"{len(execution.applied)} action(s) applied and verified; "
f"{len(execution.retired)} retirement(s) completed; "
f"{len(execution.skipped)} unchanged/skipped."
)
return 0