Skip to content

Commit 8304eaa

Browse files
egorpavlikhinclaude
andcommitted
feat: show machine/gateway as top-level node in live-status output
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>
1 parent 224a222 commit 8304eaa

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

pkg/cmd/kubernetes/live-status/live-status.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,16 @@ func printSummary(cmd *cobra.Command, summary *StatusSummary) error {
237237
func printFullStatus(cmd *cobra.Command, response *LiveStatusResponse) error {
238238
var allFlat []FlatResource
239239
for _, machine := range response.MachineStatuses {
240-
allFlat = append(allFlat, flattenResources(machine.Resources, 0)...)
240+
// Insert machine/gateway as a top-level grouping node
241+
allFlat = append(allFlat, FlatResource{
242+
Depth: 0,
243+
Resource: KubernetesLiveStatusResource{
244+
Name: machine.MachineId,
245+
Kind: "Machine",
246+
HealthStatus: machine.Status,
247+
},
248+
})
249+
allFlat = append(allFlat, flattenResources(machine.Resources, 1)...)
241250
}
242251

243252
if len(allFlat) == 0 {

pkg/cmd/kubernetes/live-status/live-status_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,46 @@ func TestKubernetesLiveStatus(t *testing.T) {
169169
assert.Contains(t, out, `"Healthy"`)
170170
}},
171171

172+
{"table output shows machine as top-level node", func(t *testing.T, api *testutil.MockHttpServer, rootCmd *cobra.Command, stdOut *bytes.Buffer, stdErr *bytes.Buffer) {
173+
cmdReceiver := testutil.GoBegin2(func() (*cobra.Command, error) {
174+
defer api.Close()
175+
rootCmd.SetArgs([]string{"kubernetes", "live-status", "--project", "Fire Project", "--environment", "Production", "--no-prompt", "-f", "table"})
176+
return rootCmd.ExecuteC()
177+
})
178+
179+
respondToSpaceScopedInit(t, api)
180+
181+
api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/Fire Project").RespondWith(fireProject)
182+
api.ExpectRequest(t, "GET", "/api/Spaces-1/environments?partialName=Production").
183+
RespondWith(map[string]any{
184+
"Items": []any{
185+
map[string]any{
186+
"Id": "Environments-1",
187+
"Name": "Production",
188+
"Links": map[string]string{
189+
"Self": "/api/Spaces-1/environments/Environments-1",
190+
},
191+
},
192+
},
193+
"ItemsPerPage": 30,
194+
"TotalResults": 1,
195+
})
196+
197+
api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/Projects-22/environments/Environments-1/untenanted/livestatus").
198+
RespondWith(liveStatusResponse)
199+
200+
_, err := testutil.ReceivePair(cmdReceiver)
201+
assert.Nil(t, err)
202+
203+
out := stdOut.String()
204+
// Machine should appear as a top-level node
205+
assert.Contains(t, out, "Machines-1")
206+
assert.Contains(t, out, "Machine")
207+
// Resources should be indented under the machine
208+
assert.Contains(t, out, " my-deployment")
209+
assert.Contains(t, out, " my-deployment-abc123")
210+
}},
211+
172212
{"summary-only adds query parameter", func(t *testing.T, api *testutil.MockHttpServer, rootCmd *cobra.Command, stdOut *bytes.Buffer, stdErr *bytes.Buffer) {
173213
cmdReceiver := testutil.GoBegin2(func() (*cobra.Command, error) {
174214
defer api.Close()

0 commit comments

Comments
 (0)