Skip to content

feat: add channel list, view, and delete commands#609

Open
NickJosevski wants to merge 3 commits into
mainfrom
nj/channel-list-view-delete
Open

feat: add channel list, view, and delete commands#609
NickJosevski wants to merge 3 commits into
mainfrom
nj/channel-list-view-delete

Conversation

@NickJosevski
Copy link
Copy Markdown
Contributor

@NickJosevski NickJosevski commented Jun 2, 2026

What

Adds three new subcommands to octopus channel:

  • list — list channels for a project, with --partial-name client-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/--confirm flag for automation.

All three support the standard table/json/basic output formats.

Notable details

  • Config-as-Code safety: delete surfaces 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.
  • Name/ID resolution: view and delete try a direct GetByID first, then fall back to a project-scoped channel lookup when given a name or slug. delete verifies the resolved channel actually belongs to the named project before deleting.

Heads-up: view/create asymmetry

view deliberately surfaces fields that the existing channel create command 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 extend create (and possibly add update). 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 -p flag, --partial-name filter ✅
  • view — by name, ID, and slug; table/json/basic ✅
  • delete — by name with -y ✅; deleting the default channel surfaces the server's You cannot delete the default channel. cleanly ✅; non-existent channel returns no channel found with name of <x>
  • CaC warning — verified against a real version-controlled project (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-prompt automation mode ✅

Two findings:

  1. Fixed in this PR — viewing the default channel rendered an empty Lifecycle: () line, because the server returns a null LifecycleId (the default channel inherits the project lifecycle). Now displays Inherited from project, with a regression test.
  2. Known limitation (not fixed here) — the live server returns a Slug field on channels, but go-octopusdeploy v2.108.0's channels.Channel struct does not expose it, so view/list cannot 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.

ok  github.com/OctopusDeploy/cli/pkg/cmd/channel/delete
ok  github.com/OctopusDeploy/cli/pkg/cmd/channel/list
ok  github.com/OctopusDeploy/cli/pkg/cmd/channel/view

🤖 Generated with Claude Code

NickJosevski and others added 3 commits May 22, 2026 22:02
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>
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.

1 participant