Skip to content

Commit 2758745

Browse files
author
jmccormick2001
committed
add better docs around all special cluster name including pgo CLI help text and hugo docs, also fix all support in label command
1 parent c8265b7 commit 2758745

File tree

9 files changed

+33
-11
lines changed

9 files changed

+33
-11
lines changed

apiserver/clusterservice/scaleimpl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func ScaleCluster(name, replicaCount, resourcesConfig, storageConfig, nodeLabel,
3939
response := msgs.ClusterScaleResponse{}
4040
response.Status = msgs.Status{Code: msgs.Ok, Msg: ""}
4141

42+
if name == "all" {
43+
response.Status.Code = msgs.Error
44+
response.Status.Msg = "all is not allowed for the scale command"
45+
return response
46+
}
47+
4248
cluster := crv1.Pgcluster{}
4349
err = apiserver.RESTClient.Get().
4450
Resource(crv1.PgclusterResourcePlural).

apiserver/labelservice/labelimpl.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ func Label(request *msgs.LabelRequest) msgs.LabelResponse {
5858
}
5959

6060
clusterList := crv1.PgclusterList{}
61-
if request.Selector != "" {
62-
log.Debug("selector is " + request.Selector)
63-
61+
if request.Selector == "" || request.Args[0] == "all" {
6462
err = kubeapi.GetpgclustersBySelector(apiserver.RESTClient,
6563
&clusterList, request.Selector, apiserver.Namespace)
6664
if err != nil {
@@ -75,7 +73,7 @@ func Label(request *msgs.LabelRequest) msgs.LabelResponse {
7573
return resp
7674
}
7775
} else {
78-
//each arg represents a cluster name or the special 'all' value
76+
//each arg represents a cluster name
7977
items := make([]crv1.Pgcluster, 0)
8078
for _, cluster := range request.Args {
8179
result := crv1.Pgcluster{}

apiserver/upgradeservice/upgradeimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func CreateUpgrade(request *msgs.CreateUpgradeRequest) msgs.CreateUpgradeRespons
170170
&cl, arg, apiserver.Namespace)
171171
if !found {
172172
response.Status.Code = msgs.Error
173-
response.Status.Msg = err.Error()
173+
response.Status.Msg = arg + " is not a valid pgcluster"
174174
return response
175175
}
176176

hugo/content/getting-started/_index.adoc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ export CO_APISERVER_URL=https://10.104.47.110:8443
2020
pgo version
2121
....
2222

23+
== Cluster Names
24+
25+
Many of the pgo commands take in a cluster name, in some cases
26+
the special name of *all* is accepted which will cause the
27+
command to be applied to all PostgreSQL clusters. For
28+
example:
29+
....
30+
pgo df all
31+
....
32+
2333
== General
2434

2535
=== Operator Version
@@ -309,7 +319,7 @@ the selected cluster, but will not delete the data or the backups unless specifi
309319

310320
==== Syntax
311321

312-
$ pgo delete cluster NAME [FLAGS]
322+
$ pgo delete cluster NAME|all [FLAGS]
313323

314324
==== Flags
315325

@@ -377,7 +387,7 @@ any and all specified options (such as whether crunchy_collect is enabled).
377387

378388
==== Syntax
379389

380-
$ pgo show cluster NAME [FLAGS]
390+
$ pgo show cluster NAME|all [FLAGS]
381391

382392
==== Flags
383393

@@ -439,7 +449,7 @@ out as connections are tried, along with the connection status.
439449

440450
==== Syntax
441451

442-
$ pgo test NAME [FLAGS]
452+
$ pgo test NAME|all [FLAGS]
443453

444454
==== Flags
445455

@@ -1000,7 +1010,7 @@ input being valid.
10001010
10011011
==== Syntax
10021012
1003-
$ pgo label [NAME] [FLAGS]
1013+
$ pgo label [NAME]|all [FLAGS]
10041014
10051015
==== Flags
10061016
@@ -1033,11 +1043,12 @@ pgo label mycluster --label=env=research
10331043
Or if you wanted to apply if to a selection of clusters:
10341044
....
10351045
pgo label --label=env=research --selector=project=xray
1046+
pgo label all --label=env=research
10361047
....
10371048
10381049
In the first example, a label of *env=research* is applied to the cluster
10391050
*mycluster*. The second example will apply the label to any clusters that
1040-
have an existing label of *project=xray* applied.
1051+
have an existing label of *project=xray* applied or to all clusters.
10411052
10421053
=== Creating SQL Policies
10431054
@@ -1131,6 +1142,7 @@ pgo show cluster --selector=policy1=pgpolicy
11311142
To delete a policy use the following form:
11321143
....
11331144
pgo delete policy policy1
1145+
pgo delete policy all
11341146
....
11351147
11361148
=== Loading Data

pgo/cmd/delete.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ var deleteClusterCmd = &cobra.Command{
197197
Short: "Delete a PostgreSQL cluster",
198198
Long: `Delete a PostgreSQL cluster. For example:
199199
200+
pgo delete cluster all
200201
pgo delete cluster mycluster`,
201202
Run: func(cmd *cobra.Command, args []string) {
202203
if len(args) == 0 && Selector == "" {

pgo/cmd/df.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var dfCmd = &cobra.Command{
3434
Long: `Displays the disk status for PostgreSQL clusters. For example:
3535
3636
pgo df mycluster
37+
pgo df all
3738
pgo df --selector=env=research`,
3839
Run: func(cmd *cobra.Command, args []string) {
3940
log.Debug("df called")

pgo/cmd/label.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var labelCmd = &cobra.Command{
3535
3636
pgo label mycluster yourcluster --label=environment=prod
3737
pgo label mycluster yourcluster --label=environment=prod --delete-label
38+
pgo label all --label=environment=prod
3839
pgo label --label=environment=prod --selector=name=mycluster
3940
pgo label --label=environment=prod --selector=status=final --dry-run`,
4041
Run: func(cmd *cobra.Command, args []string) {

pgo/cmd/show.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ var ShowClusterCmd = &cobra.Command{
194194
Short: "Show cluster information",
195195
Long: `Show a PostgreSQL cluster. For example:
196196
197+
pgo show cluster all
197198
pgo show cluster mycluster`,
198199
Run: func(cmd *cobra.Command, args []string) {
199200
if Selector == "" && len(args) == 0 {

pgo/cmd/test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ var testCmd = &cobra.Command{
3030
Short: "Test cluster connectivity",
3131
Long: `TEST allows you to test the connectivity for a cluster. For example:
3232
33-
pgo test mycluster`,
33+
pgo test mycluster
34+
pgo test --selector=env=research
35+
pgo test all`,
3436
Run: func(cmd *cobra.Command, args []string) {
3537
log.Debug("test called")
3638
if Selector == "" && len(args) == 0 {

0 commit comments

Comments
 (0)