Skip to content

feat: add SnapshotVariables for releases and runbook snapshots - #430

Open
justin-newman wants to merge 6 commits into
OctopusDeploy:mainfrom
justin-newman:feat/snapshot-variables
Open

feat: add SnapshotVariables for releases and runbook snapshots#430
justin-newman wants to merge 6 commits into
OctopusDeploy:mainfrom
justin-newman:feat/snapshot-variables

Conversation

@justin-newman

@justin-newman justin-newman commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Adds two package-level client functions that refresh ("re-snapshot") the variable snapshot on an existing release or runbook snapshot, by POSTing to the server's snapshot-variables endpoints:

  • releases.SnapshotVariables(client, spaceID, releaseID) (*Release, error)POST /api/{spaceId}/releases/{releaseId}/snapshot-variables
  • runbooks.SnapshotVariables(client, spaceID, snapshotID) (*RunbookSnapshot, error)POST /api/{spaceId}/runbookSnapshots/{snapshotId}/snapshot-variables

Both follow the existing package conventions: validate parameters, expand a uritemplates template, and call newclient.Post. Each mirrors its neighbouring function's validation-error style — releases.SnapshotVariables uses CreateInvalidParameterError (like GetReleaseDeploymentTemplate); runbooks.SnapshotVariables uses CreateRequiredParameterIsEmptyOrNilError (like GetSnapshot).

Two new URI templates are added in uritemplates/links.go. Changes are purely additive (+86 lines, no existing behaviour modified).

Why

Requested during review of OctopusDeploy/cli#589: the new octopus release update-variables and octopus runbook snapshot update-variables commands should call the go client rather than hand-rolling the HTTP request, so the capability is reusable outside the CLI.

Consumer / ordering

OctopusDeploy/cli#589 depends on this PR. Once this merges and a version is tagged, cli#589 will bump its go-octopusdeploy dependency to that version and drop its temporary local replace directive — so cli#589 can be approved/merged as soon as this lands.

Tests

Added validation unit tests for both functions (release_service_test.go, runbook_service_test.go) covering the client/spaceID/id required-parameter checks, following the existing test conventions in each package.

@hnrkndrssn hnrkndrssn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Function names should be structured as [Verb][Noun] and as these functions update snapshot variables I've suggested a couple of changes, other than that this is looking good 👍

Comment thread pkg/releases/release_service.go Outdated
Comment thread pkg/runbooks/runbook_service.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends the go-octopusdeploy Go client with two new package-level helpers to “re-snapshot” variables for existing Releases and Runbook Snapshots by POSTing to the Octopus Server snapshot-variables endpoints.

Changes:

  • Added releases.SnapshotVariables(client, spaceID, releaseID) to POST to the release snapshot-variables endpoint and return the updated Release.
  • Added runbooks.SnapshotVariables(client, spaceID, snapshotID) to POST to the runbook snapshot snapshot-variables endpoint and return the updated RunbookSnapshot.
  • Added URI template constants plus unit tests covering required-parameter validation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uritemplates/links.go Adds new URI templates for release and runbook snapshot variable re-snapshot endpoints.
pkg/runbooks/runbook_service.go Introduces SnapshotVariables helper for runbook snapshots.
pkg/runbooks/runbook_service_test.go Adds validation test coverage for the new runbook helper.
pkg/releases/release_service.go Introduces SnapshotVariables helper for releases.
pkg/releases/release_service_test.go Adds validation test coverage for the new release helper.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/runbooks/runbook_service.go Outdated
…ariables for releases and runbooks

Rename SnapshotVariables to UpdateSnapshotVariables in releases and runbooks services and update corresponding tests and validation/error messages. This makes the intent (refreshing/resnapshotting variables) clearer and keeps naming consistent across the codebase.
@justin-newman

Copy link
Copy Markdown
Author

@hnrkndrssn thank you for that feedback. I implemented your suggestions as well as the one from Copilot.

@hnrkndrssn

Copy link
Copy Markdown
Contributor

Hey @justin-newman just wanted to let you know I've had a look at the latest changes and they're all good now but due to GitHub workflows and required checks I need to take your changes and prepare a new PR that is not from a fork 😞 I'll jump on this first thing on Monday and get this all sorted out.

@justin-newman

Copy link
Copy Markdown
Author

Hey @justin-newman just wanted to let you know I've had a look at the latest changes and they're all good now but due to GitHub workflows and required checks I need to take your changes and prepare a new PR that is not from a fork 😞 I'll jump on this first thing on Monday and get this all sorted out.

No problem, I saw that issue that came up and understand completely. I'm just excited to get that in and work it into my pipelines.

@justin-newman

Copy link
Copy Markdown
Author

@hnrkndrssn could you link that new PR here when you get a chance?

@hnrkndrssn

Copy link
Copy Markdown
Contributor

@justin-newman yep, I will link the new PR to this original PR 👍

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.

3 participants