feat: add SnapshotVariables for releases and runbook snapshots - #430
feat: add SnapshotVariables for releases and runbook snapshots#430justin-newman wants to merge 6 commits into
Conversation
hnrkndrssn
left a comment
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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 releasesnapshot-variablesendpoint and return the updatedRelease. - Added
runbooks.SnapshotVariables(client, spaceID, snapshotID)to POST to the runbook snapshotsnapshot-variablesendpoint and return the updatedRunbookSnapshot. - 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.
…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.
|
@hnrkndrssn thank you for that feedback. I implemented your suggestions as well as the one from Copilot. |
|
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. |
|
@hnrkndrssn could you link that new PR here when you get a chance? |
|
@justin-newman yep, I will link the new PR to this original PR 👍 |
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-variablesendpoints:releases.SnapshotVariables(client, spaceID, releaseID) (*Release, error)→POST /api/{spaceId}/releases/{releaseId}/snapshot-variablesrunbooks.SnapshotVariables(client, spaceID, snapshotID) (*RunbookSnapshot, error)→POST /api/{spaceId}/runbookSnapshots/{snapshotId}/snapshot-variablesBoth follow the existing package conventions: validate parameters, expand a
uritemplatestemplate, and callnewclient.Post. Each mirrors its neighbouring function's validation-error style —releases.SnapshotVariablesusesCreateInvalidParameterError(likeGetReleaseDeploymentTemplate);runbooks.SnapshotVariablesusesCreateRequiredParameterIsEmptyOrNilError(likeGetSnapshot).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-variablesandoctopus runbook snapshot update-variablescommands 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-octopusdeploydependency to that version and drop its temporary localreplacedirective — 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.