Skip to content

Commit 0a2c792

Browse files
author
Jeff McCormick
committed
fix pgo show cluster selector logic, add label to pgcluster upon creation
1 parent d680922 commit 0a2c792

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

client/cmd/cluster.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ func showCluster(args []string) {
3636
myselector := labels.Everything()
3737
log.Debug("selector is " + Labelselector)
3838
if Labelselector != "" {
39+
args = make([]string, 1)
40+
args[0] = "all"
3941
myselector, err = labels.Parse(Labelselector)
4042
if err != nil {
4143
log.Error("could not parse --selector value " + err.Error())
4244
return
4345
}
4446
}
47+
48+
log.Debugf("label selector is [%v]\n", myselector)
4549
err = Tprclient.Get().
4650
Resource(tpr.CLUSTER_RESOURCE).
4751
Namespace(Namespace).
@@ -69,7 +73,7 @@ func showCluster(args []string) {
6973
if PostgresVersion == "" || (PostgresVersion != "" && cluster.Spec.POSTGRES_FULL_VERSION == PostgresVersion) {
7074
fmt.Println("cluster : " + cluster.Spec.Name + " (" + cluster.Spec.POSTGRES_FULL_VERSION + ")")
7175
log.Debug("listing cluster " + arg)
72-
fmt.Printf("last password update %v\n", cluster.Spec.PSW_LAST_UPDATE)
76+
log.Debugf("last password update %v\n", cluster.Spec.PSW_LAST_UPDATE)
7377
//list the deployments
7478
listDeployments(cluster.Spec.Name)
7579
//list the replicasets
@@ -310,9 +314,13 @@ func getClusterParams(name string) *tpr.PgCluster {
310314
spec.BACKUP_PVC_NAME = BackupPVC
311315
}
312316

317+
labels := make(map[string]string)
318+
labels["name"] = name
319+
313320
newInstance := &tpr.PgCluster{
314321
Metadata: meta_v1.ObjectMeta{
315-
Name: name,
322+
Name: name,
323+
Labels: labels,
316324
},
317325
Spec: spec,
318326
}

client/cmd/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var ShowClusterCmd = &cobra.Command{
164164
165165
pgo show cluster mycluster`,
166166
Run: func(cmd *cobra.Command, args []string) {
167-
if len(args) == 0 {
167+
if Labelselector == "" && len(args) == 0 {
168168
log.Error("cluster name(s) required for this command")
169169
} else {
170170
showCluster(args)

0 commit comments

Comments
 (0)