Skip to content

Commit 9e75d66

Browse files
tjmoore4Jonathan S. Katz
authored andcommitted
Add ports to pgo show cluster output
This update adds the service port and protocol information to the 'pgo show cluster' output. Issue: [ch9563]
1 parent 8719ac7 commit 9e75d66

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

internal/apiserver/clusterservice/clusterimpl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ func getServices(cluster *crv1.Pgcluster, ns string) ([]msgs.ShowClusterService,
308308
d.ClusterName = cluster.Name
309309
}
310310
d.ClusterIP = p.Spec.ClusterIP
311+
for _, port := range p.Spec.Ports {
312+
d.ClusterPorts = append(d.ClusterPorts, strconv.Itoa(int(port.Port))+"/"+string(port.Protocol))
313+
}
311314
if len(p.Spec.ExternalIPs) > 0 {
312315
d.ExternalIP = p.Spec.ExternalIPs[0]
313316
}

pgo/cmd/cluster.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@ func printCluster(detail *msgs.ShowClusterDetail) {
220220

221221
for _, service := range detail.Services {
222222
if service.ExternalIP == "" {
223-
fmt.Println(TreeBranch + "service : " + service.Name + " - ClusterIP (" + service.ClusterIP + ")")
223+
fmt.Println(TreeBranch + "service : " + service.Name + " - ClusterIP (" + service.ClusterIP + ")" + " - Ports (" +
224+
strings.Trim(strings.Join(strings.Fields(fmt.Sprint(service.ClusterPorts)), ", "), "[]") + ")")
224225
} else {
225-
fmt.Println(TreeBranch + "service : " + service.Name + " - ClusterIP (" + service.ClusterIP + ") ExternalIP (" + service.ExternalIP + ")")
226+
fmt.Println(TreeBranch + "service : " + service.Name + " - ClusterIP (" + service.ClusterIP + ") ExternalIP (" + service.ExternalIP +
227+
")" + " - Ports (" + strings.Trim(strings.Join(strings.Fields(fmt.Sprint(service.ClusterPorts)), ", "), "[]") + ")")
226228
}
227229
}
228230

pkg/apiservermsgs/clustermsgs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ type ShowClusterService struct {
243243
Name string
244244
Data string
245245
ClusterIP string
246+
ClusterPorts []string
246247
ExternalIP string
247248
ClusterName string
248249
Pgbouncer bool

0 commit comments

Comments
 (0)