feat: apply predecessor plan artifact instead of re-planning#47
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Terraform runner to support “apply from predecessor plan” when the run-details response includes a planArtifact HAL link, ensuring the APPLY run uses the exact plan previewed during DETECT (and fails explicitly on download/staleness rather than silently re-planning).
Changes:
- Thread a new
planArtifactUrl(andrunApi) throughWorker/SingleRunWorkerintoTfApplyCommand. - Implement plan-artifact download +
terraform apply <plan>behavior, including explicit failure handling for download/apply errors. - Extend the meshapi client with
DownloadArtifact()and add scenario tests for apply-with/without plan artifact and download failure.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tf-block-runner/tfrun/worker.go | Passes plan-artifact URL + API client into TF command params for worker runs. |
| tf-block-runner/tfrun/singlerunworker.go | Mirrors worker wiring for single-run execution. |
| tf-block-runner/tfrun/tfcmd.go | Extends TF command params to include predecessor plan URL + Run API client. |
| tf-block-runner/tfrun/tfapply.go | Applies a downloaded predecessor plan via tfexec.DirOrPlan(...) when provided. |
| tf-block-runner/tfrun/runapi.go | Adds DownloadPredecessorArtifact to the runner Run API wrapper. |
| tf-block-runner/tfrun/run.go | Stores PlanArtifactUrl on internal Run. |
| tf-block-runner/tfrun/dtos.go | Maps _links.planArtifact.href into internal Run.PlanArtifactUrl. |
| tf-block-runner/tfrun/worker_scenario_test.go | Adds HTTP mock routing and helper to return run-details containing the plan-artifact link. |
| tf-block-runner/tfrun/tfplan_scenario_test.go | Adds scenario tests for apply-with-plan (success), apply-without-plan, and download failure. |
| go-meshapi-client/meshapi/dtos.go | Adds planArtifact link to LinksDTO. |
| go-meshapi-client/meshapi/client.go | Adds DownloadArtifact() for authenticated raw artifact downloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7b695e2 to
6523212
Compare
grubmeshi
reviewed
Jun 30, 2026
6523212 to
afb751f
Compare
afb751f to
bf8f7c7
Compare
30c11c1 to
21f9702
Compare
When the runner-facing checkout response carries a planArtifact HAL link, the TF runner downloads the predecessor DETECT run's saved terraform plan with the run bearer token and runs `terraform apply plan.tfplan` instead of a fresh apply. Download failures and stale/invalid saved-plan errors fail the run with an explanatory message (no silent fallback to a fresh apply); absence of the link keeps the existing plain apply, so behavior is unchanged for non-predecessored runs. Both Worker and SingleRunWorker thread the new field identically.
21f9702 to
8e1fe0c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the runner-facing checkout response carries a planArtifact HAL link, the TF runner downloads the predecessor DETECT run's saved terraform plan with the run bearer token and runs
terraform apply plan.tfplaninstead of a fresh apply.Download failures and stale/invalid saved-plan errors fail the run with an explanatory message (no silent fallback to a fresh apply); absence of the link keeps the existing plain apply, so behavior is unchanged for non-predecessored runs. Both Worker and SingleRunWorker thread the new field identically.