feat: add channel list, view, and delete commands#609
Open
NickJosevski wants to merge 3 commits into
Open
Conversation
Command-line --variable arguments to `octopus runbook run` were being silently dropped when the user went through the interactive prompts (without --no-prompt). Inside askRunbookPreviewVariables, the result map was rebuilt from the form preview's controls only, so any CLI variable whose name didn't match a control was discarded. The resulting runbook run fell back to the prompted variables' default values and the printed Automation Command was missing the -v args. This change extracts the variable-resolution logic into a pure helper, resolveRunbookPreviewVariables, and seeds the result map with the caller-supplied CLI variables before processing controls. Variables that do match a control are still canonicalised to the control's name (preserving the prior case-fixing behaviour). Variables without a matching control are now passed through unchanged. Adds unit tests covering: passthrough of unmatched CLI vars, canonicalisation of mismatched casing, no-prompt when CLI satisfies a required control, sensitive-variable tracking, and the still-working prompt path for unprovided required controls. A similar pattern exists in pkg/cmd/release/deploy/deploy.go around line 854; not changed here to keep this PR scoped to the reported bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds three new subcommands to `octopus channel`: - `list` — list channels for a project, with `--partial-name` filtering - `view` — view a channel, resolving lifecycle name and exposing rule counts, tenant tags, and ephemeral-environment fields - `delete` — delete a channel, with a Config-as-Code warning for version-controlled projects Each supports the standard table/json/basic output formats and includes unit tests covering automation, interactive, and name-lookup-fallback paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Live testing against an Octopus instance revealed that the default channel returns a null LifecycleId (it inherits the project's lifecycle). The view command rendered this as an empty "Lifecycle: ()" line in basic output and a blank cell in table output. Display "Inherited from project" instead, and add a unit test covering the default-channel case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds three new subcommands to
octopus channel:list— list channels for a project, with--partial-nameclient-side filtering. Accepts the project as a positional arg or via-p/--project.view— view a single channel by name, ID, or slug. Resolves the lifecycle name for display and exposes the richer channel fields (version rule counts, Git reference/resource rule counts, tenant tags, custom field definitions, and ephemeral-environment settings). Supports--web.delete— delete a channel by name, ID, or slug. Includes a confirmation prompt in interactive mode and a-y/--confirmflag for automation.All three support the standard
table/json/basicoutput formats.Notable details
deletesurfaces a warning in interactive mode when the project is version-controlled, since the server does not guard against deleting a channel referenced by OCL deployments.viewanddeletetry a directGetByIDfirst, then fall back to a project-scoped channel lookup when given a name or slug.deleteverifies the resolved channel actually belongs to the named project before deleting.Heads-up: view/create asymmetry
viewdeliberately surfaces fields that the existingchannel createcommand does not yet support — version rules, Git reference/resource rules, tenant tag scoping, and ephemeral-environment settings. This is a read-only display only; it does not add any write/edit capability for those fields. Reviewers should expect users to ask "why can I see these but not set them via CLI?", which would invite a follow-up to extendcreate(and possibly addupdate). Flagging so the scope of this PR is clear: it adds list/view/delete, not richer channel authoring.Live testing
Smoke-tested all three commands end-to-end against a local Octopus instance:
list— table/json/basic, positional-arg and-pflag,--partial-namefilter ✅view— by name, ID, and slug; table/json/basic ✅delete— by name with-y✅; deleting the default channel surfaces the server'sYou cannot delete the default channel.cleanly ✅; non-existent channel returnsno channel found with name of <x>✅file://-backed,IsVersionControlled: true): the warning shows in interactive mode before both a successful delete and a default-channel rejection, and is correctly suppressed in--no-promptautomation mode ✅Two findings:
Lifecycle: ()line, because the server returns a nullLifecycleId(the default channel inherits the project lifecycle). Now displaysInherited from project, with a regression test.Slugfield on channels, butgo-octopusdeploy v2.108.0'schannels.Channelstruct does not expose it, soview/listcannot show channel slugs. Surfacing slugs needs an SDK bump; out of scope for this PR.Tests
Unit tests for each command covering automation mode, interactive mode, name-lookup fallback, output formats, the CaC-deletion warning, and the inherited-lifecycle default-channel case.
🤖 Generated with Claude Code