feat: Add kubernetes live-status command - #590
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each machine or Argo CD gateway is now always displayed as a top-level grouping node, with its resources indented underneath. This makes it clear which machine owns which resources when a project-environment pair has multiple deployment targets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A project and environment whose deployment process cannot report live object status returns Summary.Status "NotSupported" with no machine statuses, which read as "No Kubernetes resources found." That sends the user looking for a data problem, when the cause is the deployment process using script-based Kubernetes steps, or a target whose Kubernetes monitor is not enabled. Reproduced against a local Octopus with a Kubernetes agent: every script-step project reports NotSupported, a raw-YAML project reports Healthy with its resources. An empty result on a supported project still reports no resources found; the two are different situations. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The grouping row printed the raw machine ID (Machines-21), where every other command resolves machine IDs to names. Look the name up, falling back to the ID if the lookup fails, since this is a display detail and should not fail the command. NewRootResource in the test fake had no Machines link, so machine lookups failed without issuing a request and could not be asserted on; added it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The json output format was re-marshalled from the structs the table needs, which silently dropped every other field the server reports. Against a local Octopus with a Kubernetes monitor, that lost ArgoCDInstanceStatuses, and per resource ResourceId, DesiredResourceId, MachineId, OrphanedAt and the DeletionTask fields, plus Summary.TotalOrphanCount and SyncStatusMessage -- so orphaned and pending-deletion resources were invisible to a programmatic caller. Print the response body instead. The structs stay as they are; they model what the table renders, which is not the same contract as -f json. Also drops the Json mapper from PrintArray, which was unreachable because the json format returns earlier. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Question on It was re-marshalling
So orphaned and pending-deletion resources were invisible to anything consuming the JSON, and Argo CD instance statuses were absent entirely. I've made it print the response body instead, which brings that to zero missing fields. Was the narrower shape intentional — a deliberately stable CLI-owned contract, insulated from server changes — or just a side effect of reusing the structs the table needs? If it was intentional I'll happily revert that commit and instead widen the structs to cover the fields above, though then they need maintaining as the server adds more. Worth noting either way: the struct fields you did model all match the real payload, |
Summary
octopus kubernetes live-statuscommand (aliased asoctopus k8s live-status) to query real-time health and sync status of Kubernetes resources deployed via Octopus Deploy--summary-onlymode for quick health checksExample
Files changed
pkg/cmd/kubernetes/kubernetes.go— New top-levelkubernetescommand group withk8saliaspkg/cmd/kubernetes/live-status/live-status.go— Command implementation with flags, API call, and output formattingpkg/cmd/kubernetes/live-status/live-status_test.go— 6 unit tests covering automation mode, JSON output, summary mode, and aliaspkg/cmd/root/root.go— Register new kubernetes commandexamples.md— Add usage examplesREADME.md— Add kubernetes to code structure docsTest plan
go build ./...compiles successfullygo test ./pkg/cmd/kubernetes/...— all 6 tests passgo test ./pkg/...— full test suite passes with no regressions🤖 Generated with Claude Code