Skip to content

Commit e6957a7

Browse files
wpjuniorclaude
andcommitted
fix: update info and autoscale output format with aligned labels
- Change autoscale output from two separate lines to a single compact header: "Autoscale: (min replicas: X, max replicas: Y)" - Add fixed-width padding to info template labels for better alignment (Name, Dashboard, Description, Tags, etc.) - Remove redundant "Autoscale:" header from info template since writeAutoscale now includes it - Update test expectations in autoscale_test.go and info_test.go to match the new output format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c08c277 commit e6957a7

File tree

4 files changed

+43
-49
lines changed

4 files changed

+43
-49
lines changed

cmd/plugin/rpaasv2/cmd/autoscale.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ func writeAutoscale(w io.Writer, autoscale *autogenerated.Autoscale) {
246246
return
247247
}
248248

249-
fmt.Fprintf(w, "min replicas: %d\n", autoscale.MinReplicas)
250-
fmt.Fprintf(w, "max replicas: %d\n", autoscale.MaxReplicas)
249+
fmt.Fprintf(w, "Autoscale: (min replicas: %d, max replicas: %d)\n", autoscale.MinReplicas, autoscale.MaxReplicas)
251250

252251
table := tablewriter.NewWriter(w)
253252
table.SetHeader([]string{"Triggers", "trigger details"})

cmd/plugin/rpaasv2/cmd/autoscale_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ func TestGetAutoscale(t *testing.T) {
5151
Rps: autogenerated.PtrInt32(100),
5252
})
5353
}),
54-
expected: `min replicas: 2
55-
max replicas: 5
54+
expected: `Autoscale: (min replicas: 2, max replicas: 5)
5655
+----------+-----------------+
5756
| Triggers | trigger details |
5857
+----------+-----------------+
@@ -77,8 +76,7 @@ max replicas: 5
7776
},
7877
})
7978
}),
80-
expected: `min replicas: 0
81-
max replicas: 100
79+
expected: `Autoscale: (min replicas: 0, max replicas: 100)
8280
+-------------+-------------------------------------------------------------+
8381
| Triggers | trigger details |
8482
+-------------+-------------------------------------------------------------+

cmd/plugin/rpaasv2/cmd/info.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,33 @@ var instanceInfoTemplate = template.Must(template.New("rpaasv2.instance.info").
8080
Funcs(newFuncMap()).
8181
Parse(`
8282
{{- $instance := . -}}
83-
Name: {{ .Name }}
83+
Name: {{ .Name }}
8484
{{- with .Dashboard}}
85-
Dashboard: {{ . }}
85+
Dashboard: {{ . }}
8686
{{- end }}
8787
{{- with .Description}}
88-
Description: {{ . }}
88+
Description: {{ . }}
8989
{{- end }}
90-
Tags: {{ join ", " .Tags }}
90+
Tags: {{ join ", " .Tags }}
9191
{{- with .Annotations}}
92-
Annotations: {{ join ", " . }}
92+
Annotations: {{ join ", " . }}
9393
{{- end }}
94-
Team owner: {{ .Team }}
95-
Plan: {{ .Plan }}
94+
Team owner: {{ .Team }}
95+
Plan: {{ .Plan }}
9696
{{- with .Flavors}}
97-
Flavors: {{ join ", " . }}
97+
Flavors: {{ join ", " . }}
9898
{{- end }}
9999
{{- with .Shutdown }}
100-
Shutdown: {{ . }}
100+
Shutdown: {{ . }}
101101
{{- end }}
102102
{{- with .Cluster}}
103-
Cluster: {{ . }}
103+
Cluster: {{ . }}
104104
{{- end }}
105105
{{- with .Pool }}
106-
Pool: {{ . }}
106+
Pool: {{ . }}
107107
{{- end }}
108108
{{- with .Image}}
109-
Image: {{ . }}
109+
Image: {{ . }}
110110
{{- end }}
111111
112112
{{- with .PlanOverride }}{{ "\n" }}
@@ -121,7 +121,6 @@ Pods: (current: {{ len .Pods }}{{ if not .Autoscale }} / desired: {{ .Replicas }
121121
{{- end }}
122122
123123
{{- with .Autoscale }}
124-
Autoscale:
125124
{{ formatAutoscale . }}
126125
{{- end }}
127126

cmd/plugin/rpaasv2/cmd/info_test.go

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,17 @@ func TestInfo(t *testing.T) {
327327
}, nil
328328
},
329329
},
330-
expected: `Name: my-instance
331-
Dashboard: https://grafana.mycompany.io/my-instance
332-
Description: some description
333-
Tags: tag1, tag2, tag3
334-
Annotations: key1=val1, key2=val2, key3=val3
335-
Team owner: some-team
336-
Plan: basic
337-
Flavors: flavor1, flavor2, flavor-N
338-
Cluster: my-dedicated-cluster
339-
Pool: my-pool
340-
Image: tsuru/nginx-tsuru:1.26.3
330+
expected: `Name: my-instance
331+
Dashboard: https://grafana.mycompany.io/my-instance
332+
Description: some description
333+
Tags: tag1, tag2, tag3
334+
Annotations: key1=val1, key2=val2, key3=val3
335+
Team owner: some-team
336+
Plan: basic
337+
Flavors: flavor1, flavor2, flavor-N
338+
Cluster: my-dedicated-cluster
339+
Pool: my-pool
340+
Image: tsuru/nginx-tsuru:1.26.3
341341
342342
Plan overrides:
343343
{
@@ -396,9 +396,7 @@ Errors:
396396
| | | uuid) |
397397
+--------------------+------------------------------+----------------------------------------------+
398398
399-
Autoscale:
400-
min replicas: 2
401-
max replicas: 5
399+
Autoscale: (min replicas: 2, max replicas: 5)
402400
+----------+-----------------+
403401
| Triggers | trigger details |
404402
+----------+-----------------+
@@ -588,14 +586,14 @@ Events:
588586
}, nil
589587
},
590588
},
591-
expected: `Name: my-instance
592-
Description: some description
593-
Tags: tag1, tag2, tag3
594-
Annotations: key1=val1, key2=val2, key3=val3
595-
Team owner: some-team
596-
Plan: basic
597-
Flavors: flavor1, flavor2, flavor-N
598-
Cluster: my-dedicated-cluster
589+
expected: `Name: my-instance
590+
Description: some description
591+
Tags: tag1, tag2, tag3
592+
Annotations: key1=val1, key2=val2, key3=val3
593+
Team owner: some-team
594+
Plan: basic
595+
Flavors: flavor1, flavor2, flavor-N
596+
Cluster: my-dedicated-cluster
599597
600598
Pods: (current: 2 / desired: 3)
601599
+------------------------------+---------------+-------------+----------+-----+------+--------+
@@ -685,14 +683,14 @@ Pods: (current: 2 / desired: 3)
685683
}, nil
686684
},
687685
},
688-
expected: `Name: my-instance
689-
Description: some description
690-
Tags: tag1, tag2, tag3
691-
Annotations: key1=val1, key2=val2, key3=val3
692-
Team owner: some-team
693-
Plan: basic
694-
Flavors: flavor1, flavor2, flavor-N
695-
Cluster: my-dedicated-cluster
686+
expected: `Name: my-instance
687+
Description: some description
688+
Tags: tag1, tag2, tag3
689+
Annotations: key1=val1, key2=val2, key3=val3
690+
Team owner: some-team
691+
Plan: basic
692+
Flavors: flavor1, flavor2, flavor-N
693+
Cluster: my-dedicated-cluster
696694
697695
Pods: (current: 2 / desired: 3)
698696
+------------------------------+---------------+-------------+----------+-----+

0 commit comments

Comments
 (0)