Skip to content

feat: apply predecessor plan artifact instead of re-planning#47

Merged
sttomm merged 2 commits into
mainfrom
feature/CU-86c9pajk4_runner-apply-predecessor-plan
Jul 2, 2026
Merged

feat: apply predecessor plan artifact instead of re-planning#47
sttomm merged 2 commits into
mainfrom
feature/CU-86c9pajk4_runner-apply-predecessor-plan

Conversation

@sttomm

@sttomm sttomm commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (and runApi) through Worker/SingleRunWorker into TfApplyCommand.
  • 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.

Comment thread go-meshapi-client/meshapi/client.go Outdated
@sttomm sttomm requested a review from tfelix June 29, 2026 08:04

@tfelix tfelix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread tf-block-runner/tfrun/tfcmd.go Outdated
@sttomm sttomm force-pushed the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch from 7b695e2 to 6523212 Compare June 30, 2026 06:29
Comment thread tf-block-runner/tfrun/tfapply.go Outdated
@sttomm sttomm force-pushed the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch from 6523212 to afb751f Compare June 30, 2026 08:01
@sttomm sttomm requested a review from Copilot June 30, 2026 08:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Comment thread go-meshapi-client/meshapi/dtos.go Outdated
Comment thread go-meshapi-client/meshapi/client.go
Comment thread tf-block-runner/runner-config.yml
@sttomm sttomm force-pushed the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch from afb751f to bf8f7c7 Compare June 30, 2026 09:17
@sttomm sttomm requested a review from Copilot June 30, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Comment thread go-meshapi-client/meshapi/client.go Outdated
Comment thread tf-block-runner/tfrun/tfapply.go Outdated
@sttomm sttomm force-pushed the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch 2 times, most recently from 30c11c1 to 21f9702 Compare July 2, 2026 06:54
sttomm added 2 commits July 2, 2026 09:23
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.
@sttomm sttomm force-pushed the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch from 21f9702 to 8e1fe0c Compare July 2, 2026 07:23
@sttomm sttomm merged commit 174b77a into main Jul 2, 2026
13 checks passed
@sttomm sttomm deleted the feature/CU-86c9pajk4_runner-apply-predecessor-plan branch July 2, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants