Skip to content

Commit 4b4f83c

Browse files
committed
Part 1: Issue CrunchyData#279 Revise & Cleanup pgo CLI help text
1 parent 10123b2 commit 4b4f83c

24 files changed

+305
-301
lines changed

hugo/content/getting-started/_index.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ without having to shutdown the currently attached PostgreSQL cluster.
292292

293293
=== Delete Cluster
294294

295-
The *delete cluster* command will by default delete all associated components of
295+
The `delete cluster` command will by default delete all associated components of
296296
the selected cluster, but will not delete the data or the backups unless specified.
297297

298298
==== Syntax
@@ -524,6 +524,9 @@ The selector to use for cluster filtering.
524524
|`--pvc-name` |N/A |String |
525525
The PVC name to use for the backup instead of the default.
526526

527+
|`--backup-type` |N/A |String |
528+
The backup type to perform. Default is pgbasebackup, and both pgbasebackup and pgbackrest are valid backup types.
529+
527530
|`--storage-config` |N/A |String |
528531
The name of a Storage config in pgo.yaml to use for the cluster storage.
529532
|=========================================================

pgo/cmd/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func GetCredentials() {
107107
}
108108

109109
fullPath = pgoUser
110-
log.Debug(pgouserenvvar + " env var is being used at " + fullPath)
110+
log.Debug(pgouserenvvar + " environment variable is being used at " + fullPath)
111111
dat, err = ioutil.ReadFile(fullPath)
112112
if err != nil {
113113
fmt.Println("Error: " + fullPath + " file not found")

pgo/cmd/backrest.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ import (
3030

3131
var backRestCmd = &cobra.Command{
3232
Use: "backrest",
33-
Short: "perform a pgbackrest action",
34-
Long: `BACKREST performs a pgbackrest action, for example:
35-
pgo backrest mycluster`,
33+
Short: "Perform a pgBackRest action",
34+
Long: `BACKREST performs a pgBackRest action. For example:
35+
36+
pgo backrest mycluster`,
3637
Run: func(cmd *cobra.Command, args []string) {
3738
log.Debug("backup called")
3839
if len(args) == 0 && Selector == "" {
@@ -51,8 +52,8 @@ var backRestCmd = &cobra.Command{
5152
func init() {
5253
RootCmd.AddCommand(backRestCmd)
5354

54-
backRestCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to use for cluster filtering ")
55-
backRestCmd.Flags().BoolVarP(&NoPrompt, "no-prompt", "n", false, "--no-prompt causes there to be no command line confirmation when doing a pgbackrest command")
55+
backRestCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to use for cluster filtering.")
56+
backRestCmd.Flags().BoolVarP(&NoPrompt, "no-prompt", "n", false, "No command line confirmation.")
5657

5758
}
5859

@@ -108,7 +109,7 @@ func createBackrestBackup(args []string) {
108109
}
109110

110111
if len(response.Results) == 0 {
111-
fmt.Println("no clusters found")
112+
fmt.Println("No clusters found.")
112113
return
113114
}
114115

@@ -156,7 +157,7 @@ func showBackrest(args []string) {
156157
}
157158

158159
if len(response.Items) == 0 {
159-
fmt.Println("no backrest found")
160+
fmt.Println("No pgBackRest found.")
160161
return
161162
}
162163

pgo/cmd/backup.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ var backupCmd = &cobra.Command{
3636
Use: "backup",
3737
Short: "perform a Backup",
3838
Long: `BACKUP performs a Backup, for example:
39-
pgo backup mycluster`,
39+
40+
pgo backup mycluster`,
4041
Run: func(cmd *cobra.Command, args []string) {
4142
log.Debug("backup called")
4243
if len(args) == 0 && Selector == "" {
@@ -48,7 +49,7 @@ var backupCmd = &cobra.Command{
4849
} else if BackupType == labelutil.LABEL_BACKUP_TYPE_BASEBACKUP {
4950
createBackup(args)
5051
} else {
51-
fmt.Println("Error: You must specify either pgbasebackup or pgbackrest for the --backup-type")
52+
fmt.Println("Error: You must specify either pgbasebackup or pgbackrest for the --backup-type.")
5253
}
5354
} else {
5455
fmt.Println("Aborting...")
@@ -61,11 +62,11 @@ var backupCmd = &cobra.Command{
6162
func init() {
6263
RootCmd.AddCommand(backupCmd)
6364

64-
backupCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to use for cluster filtering ")
65-
backupCmd.Flags().StringVarP(&PVCName, "pvc-name", "", "", "The PVC name to use for the backup instead of the default backup PVC ")
66-
backupCmd.Flags().StringVarP(&BackupType, "backup-type", "", "", "The backup type to perform, default is pgbasebackup, pgbasebackup and pgbackrest are valid backup types")
67-
backupCmd.Flags().StringVarP(&StorageConfig, "storage-config", "", "", "The storage config to use for the backup volume ")
68-
backupCmd.Flags().BoolVarP(&NoPrompt, "no-prompt", "n", false, "--no-prompt causes there to be no command line confirmation when doing a backup command")
65+
backupCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to use for cluster filtering.")
66+
backupCmd.Flags().StringVarP(&PVCName, "pvc-name", "", "", "The PVC name to use for the backup instead of the default.")
67+
backupCmd.Flags().StringVarP(&StorageConfig, "storage-config", "", "", "The name of a Storage config in pgo.yaml to use for the cluster storage.")
68+
backupCmd.Flags().BoolVarP(&NoPrompt, "no-prompt", "n", false, "No command line confirmation.")
69+
backupCmd.Flags().StringVarP(&BackupType, "backup-type", "", "", "The backup type to perform. Default is pgbasebackup, and both pgbasebackup and pgbackrest are valid backup types.")
6970

7071
}
7172

@@ -112,7 +113,7 @@ func showBackup(args []string) {
112113
}
113114

114115
if len(response.BackupList.Items) == 0 {
115-
fmt.Println("no backups found")
116+
fmt.Println("No backups found.")
116117
return
117118
}
118119

@@ -183,11 +184,11 @@ func deleteBackup(args []string) {
183184

184185
if response.Status.Code == msgs.Ok {
185186
if len(response.Results) == 0 {
186-
fmt.Println("no backups found")
187+
fmt.Println("No backups found.")
187188
return
188189
}
189190
for k := range response.Results {
190-
fmt.Println("deleted backup " + response.Results[k])
191+
fmt.Println("Deleted backup " + response.Results[k])
191192
}
192193
} else {
193194
fmt.Println("Error: " + response.Status.Msg)
@@ -252,7 +253,7 @@ func createBackup(args []string) {
252253
}
253254

254255
if len(response.Results) == 0 {
255-
fmt.Println("no clusters found")
256+
fmt.Println("No clusters found.")
256257
return
257258
}
258259

pgo/cmd/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func showCluster(args []string) {
141141
}
142142

143143
if len(response.Results) == 0 {
144-
fmt.Println("no clusters found")
144+
fmt.Println("No clusters found.")
145145
return
146146
}
147147

@@ -205,7 +205,7 @@ func createCluster(args []string) {
205205
var err error
206206

207207
if len(args) == 0 {
208-
fmt.Println("Error: cluster name argument is required")
208+
fmt.Println("Error: Cluster name argument is required.")
209209
return
210210
}
211211

pgo/cmd/create.go

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ var Series int
4040
var CreateCmd = &cobra.Command{
4141
Use: "create",
4242
Short: "Create a Cluster, Policy, or User",
43-
Long: `CREATE allows you to create a new Cluster, Policy, User
44-
For example:
43+
Long: `CREATE allows you to create a new Cluster, Policy, or User. For example:
4544
46-
pgo create cluster
47-
pgo create policy
48-
pgo create user
49-
.`,
45+
pgo create cluster
46+
pgo create policy
47+
pgo create user`,
5048
Run: func(cmd *cobra.Command, args []string) {
5149
log.Debug("create called")
5250
if len(args) == 0 || (args[0] != "cluster" && args[0] != "policy") && args[0] != "user" {
@@ -61,22 +59,21 @@ pgo create user
6159
// createClusterCmd ...
6260
var createClusterCmd = &cobra.Command{
6361
Use: "cluster",
64-
Short: "Create a database cluster",
65-
Long: `Create a crunchy cluster which consist of a
66-
primary and a number of replica backends. For example:
62+
Short: "Create a PostgreSQL cluster",
63+
Long: `Create a PostgreSQL cluster consisting of a primary and a number of replica backends. For example:
6764
68-
pgo create cluster mycluster`,
65+
pgo create cluster mycluster`,
6966
Run: func(cmd *cobra.Command, args []string) {
7067
log.Debug("create cluster called")
7168
if BackupPath != "" || BackupPVC != "" {
7269
if SecretFrom == "" || BackupPath == "" || BackupPVC == "" {
73-
fmt.Println(`Error: secret-from, backup-path, backup-pvc are all required to perform a restore`)
70+
fmt.Println(`Error: The --secret-from, --backup-path, and --backup-pvc flags are all required to perform a restore.`)
7471
return
7572
}
7673
}
7774

7875
if len(args) == 0 {
79-
fmt.Println(`Error: a cluster name is required for this command`)
76+
fmt.Println(`Error: A cluster name is required for this command.`)
8077
} else {
8178
createCluster(args)
8279
}
@@ -86,19 +83,20 @@ pgo create cluster mycluster`,
8683
// createPolicyCmd ...
8784
var createPolicyCmd = &cobra.Command{
8885
Use: "policy",
89-
Short: "Create a policy",
86+
Short: "Create a SQL policy",
9087
Long: `Create a policy. For example:
91-
pgo create policy mypolicy --in-file=/tmp/mypolicy.sql`,
88+
89+
pgo create policy mypolicy --in-file=/tmp/mypolicy.sql`,
9290
Run: func(cmd *cobra.Command, args []string) {
9391
log.Debug("create policy called ")
9492
if PolicyFile == "" && PolicyURL == "" {
9593
//log.Error("--in-file or --url is required to create a policy")
96-
fmt.Println(`Error: --in-file or --url is required to create a policy`)
94+
fmt.Println(`Error: The --in-file or --url flags are required to create a policy.`)
9795
return
9896
}
9997

10098
if len(args) == 0 {
101-
fmt.Println(`Error: a policy name is required for this command`)
99+
fmt.Println(`Error: A policy name is required for this command.`)
102100
} else {
103101
createPolicy(args)
104102
}
@@ -110,15 +108,16 @@ var createIngestCmd = &cobra.Command{
110108
Use: "ingest",
111109
Short: "Create an ingest",
112110
Long: `Create an ingest. For example:
113-
pgo create ingest myingest --ingest-config=./ingest.json`,
111+
112+
pgo create ingest myingest --ingest-config=./ingest.json`,
114113
Run: func(cmd *cobra.Command, args []string) {
115114
log.Debug("create ingest called ")
116115

117116
if len(args) == 0 {
118-
fmt.Println(`Error: an ingest name is required for this command`)
117+
fmt.Println(`Error: An ingest name is required for this command.`)
119118
} else {
120119
if IngestConfig == "" {
121-
fmt.Println("Error: You must specify the ingest-config flag")
120+
fmt.Println("Error: You must specify the ingest-config flag.")
122121
return
123122
}
124123
createIngest(args)
@@ -129,18 +128,19 @@ pgo create ingest myingest --ingest-config=./ingest.json`,
129128
// createUserCmd ...
130129
var createUserCmd = &cobra.Command{
131130
Use: "user",
132-
Short: "Create a postgres user",
131+
Short: "Create a PostgreSQL user",
133132
Long: `Create a postgres user. For example:
134-
pgo create user user1 --selector=name=mycluster`,
133+
134+
pgo create user user1 --selector=name=mycluster`,
135135
Run: func(cmd *cobra.Command, args []string) {
136136
log.Debug("create user called ")
137137
if Selector == "" {
138-
fmt.Println(`Error: --selector is required to create a user`)
138+
fmt.Println(`Error: The --selector flag is required to create a user.`)
139139
return
140140
}
141141

142142
if len(args) == 0 {
143-
fmt.Println(`Error: a user name is required for this command`)
143+
fmt.Println(`Error: A user name is required for this command.`)
144144
} else {
145145
createUser(args)
146146
}
@@ -154,32 +154,33 @@ func init() {
154154
CreateCmd.AddCommand(createIngestCmd)
155155
CreateCmd.AddCommand(createUserCmd)
156156

157-
createIngestCmd.Flags().StringVarP(&IngestConfig, "ingest-config", "i", "", "The path of an ingest configuration file")
158-
createClusterCmd.Flags().BoolVarP(&PgpoolFlag, "pgpool", "", false, "If set, will cause the crunchy-pgpool container to be added to the database cluster")
159-
createClusterCmd.Flags().BoolVarP(&BackrestFlag, "pgbackrest", "", false, "If set, will cause a pgbackrest volume to be enabled for the database cluster")
160-
createClusterCmd.Flags().BoolVarP(&ArchiveFlag, "archive", "", false, "If set, will cause archive logging to be enabled for the database cluster")
157+
createClusterCmd.Flags().BoolVarP(&BackrestFlag, "pgbackrest", "", false, "Enables a pgBackRest volume for the database pod.")
158+
createClusterCmd.Flags().BoolVarP(&BadgerFlag, "pgbadger", "", false, "Adds the crunchy-pgbadger container to the database pod.")
159+
createIngestCmd.Flags().StringVarP(&IngestConfig, "ingest-config", "i", "", "Defines the path of an ingest configuration file.")
160+
createClusterCmd.Flags().BoolVarP(&PgpoolFlag, "pgpool", "", false, "Adds the crunchy-pgpool container to the database pod.")
161+
createClusterCmd.Flags().BoolVarP(&ArchiveFlag, "archive", "", false, "Enables archive logging for the database cluster.")
161162
createClusterCmd.Flags().StringVarP(&PgpoolSecret, "pgpool-secret", "", "", "The name of a pgpool secret to use for the pgpool configuration.")
162-
createClusterCmd.Flags().BoolVarP(&MetricsFlag, "metrics", "m", false, "If set, will cause the crunchy-collect container to be added to the database pod")
163-
createClusterCmd.Flags().BoolVarP(&BadgerFlag, "pgbadger", "", false, "If set, will cause the crunchy-pgbadger container to be added to the database pod")
164-
createClusterCmd.Flags().BoolVarP(&AutofailFlag, "autofail", "", false, "If set, will cause the autofailover to be enabled on this cluster")
165-
createClusterCmd.Flags().StringVarP(&CustomConfig, "custom-config", "g", "", "The name of a configMap that holds custom PG config files used to override the defaults")
163+
createClusterCmd.Flags().BoolVarP(&MetricsFlag, "metrics", "m", false, "Adds the crunchy-collect container to the database pod.")
164+
createClusterCmd.Flags().BoolVarP(&AutofailFlag, "autofail", "", false, "If set, will cause autofailover to be enabled on this cluster.")
165+
createClusterCmd.Flags().StringVarP(&CustomConfig, "custom-config", "g", "", "The name of a configMap that holds custom PostgreSQL configuration files used to override defaults.")
166166
createClusterCmd.Flags().StringVarP(&StorageConfig, "storage-config", "", "", "The name of a Storage config in pgo.yaml to use for the cluster storage.")
167167
createClusterCmd.Flags().StringVarP(&ReplicaStorageConfig, "replica-storage-config", "", "", "The name of a Storage config in pgo.yaml to use for the cluster replica storage.")
168-
createClusterCmd.Flags().StringVarP(&NodeLabel, "node-label", "", "", "The node label (key=value) to use in placing the primary database, if not set any node is used")
169-
createClusterCmd.Flags().StringVarP(&ServiceType, "service-type", "", "", "The service type to use in the Service for the PG cluster, if not set the pgo.yaml default will be used.")
170-
createClusterCmd.Flags().StringVarP(&Password, "password", "w", "", "The password to use for initial database users")
171-
createClusterCmd.Flags().StringVarP(&SecretFrom, "secret-from", "s", "", "The cluster name to use when restoring secrets")
172-
createClusterCmd.Flags().StringVarP(&BackupPVC, "backup-pvc", "p", "", "The backup archive PVC to restore from")
173-
createClusterCmd.Flags().StringVarP(&UserLabels, "labels", "l", "", "The labels to apply to this cluster")
174-
createClusterCmd.Flags().StringVarP(&BackupPath, "backup-path", "x", "", "The backup archive path to restore from")
175-
createClusterCmd.Flags().StringVarP(&PoliciesFlag, "policies", "z", "", "The policies to apply when creating a cluster, comma separated")
176-
createClusterCmd.Flags().StringVarP(&CCPImageTag, "ccp-image-tag", "c", "", "The CCPImageTag to use for cluster creation, if specified overrides the .pgo.yaml setting")
177-
createClusterCmd.Flags().IntVarP(&Series, "series", "e", 1, "The number of clusters to create in a series, defaults to 1")
178-
createClusterCmd.Flags().StringVarP(&ContainerResources, "resources-config", "r", "", "The name of a container resource configuration in pgo.yaml that holds CPU and memory requests and limits")
179-
createPolicyCmd.Flags().StringVarP(&PolicyURL, "url", "u", "", "The url to use for adding a policy")
180-
createPolicyCmd.Flags().StringVarP(&PolicyFile, "in-file", "i", "", "The policy file path to use for adding a policy")
181-
createUserCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to filter on clusters")
182-
createUserCmd.Flags().BoolVarP(&ManagedUser, "managed", "m", false, "--managed creates a user with secrets")
183-
createUserCmd.Flags().StringVarP(&UserDBAccess, "db", "b", "", "--db=userdb grants the user access to a database")
184-
createUserCmd.Flags().IntVarP(&PasswordAgeDays, "valid-days", "v", 30, "--valid-days=7 sets passwords for new users to 7 days")
168+
createClusterCmd.Flags().StringVarP(&NodeLabel, "node-label", "", "", "The node label (key=value) to use in placing the primary database. If not set, any node is used.")
169+
createClusterCmd.Flags().StringVarP(&ServiceType, "service-type", "", "", "The Service type to use for the PostgreSQL cluster. If not set, the pgo.yaml default will be used.")
170+
createClusterCmd.Flags().StringVarP(&Password, "password", "w", "", "The password to use for initial database users.")
171+
createClusterCmd.Flags().StringVarP(&SecretFrom, "secret-from", "s", "", "The cluster name to use when restoring secrets.")
172+
createClusterCmd.Flags().StringVarP(&BackupPVC, "backup-pvc", "p", "", "The backup archive PVC to restore from.")
173+
createClusterCmd.Flags().StringVarP(&UserLabels, "labels", "l", "", "The labels to apply to this cluster.")
174+
createClusterCmd.Flags().StringVarP(&BackupPath, "backup-path", "x", "", "The backup archive path to restore from.")
175+
createClusterCmd.Flags().StringVarP(&PoliciesFlag, "policies", "z", "", "The policies to apply when creating a cluster, comma separated.")
176+
createClusterCmd.Flags().StringVarP(&CCPImageTag, "ccp-image-tag", "c", "", "The CCPImageTag to use for cluster creation. If specified, overrides the pgo.yaml setting.")
177+
createClusterCmd.Flags().IntVarP(&Series, "series", "e", 1, "The number of clusters to create in a series.")
178+
createClusterCmd.Flags().StringVarP(&ContainerResources, "resources-config", "r", "", "The name of a container resource configuration in pgo.yaml that holds CPU and memory requests and limits.")
179+
createPolicyCmd.Flags().StringVarP(&PolicyURL, "url", "u", "", "The url to use for adding a policy.")
180+
createPolicyCmd.Flags().StringVarP(&PolicyFile, "in-file", "i", "", "The policy file path to use for adding a policy.")
181+
createUserCmd.Flags().StringVarP(&Selector, "selector", "s", "", "The selector to use for cluster filtering.")
182+
createUserCmd.Flags().BoolVarP(&ManagedUser, "managed", "m", false, "Creates a user with secrets that can be managed by the Operator.")
183+
createUserCmd.Flags().StringVarP(&UserDBAccess, "db", "b", "", "Grants the user access to a database.")
184+
createUserCmd.Flags().IntVarP(&PasswordAgeDays, "valid-days", "v", 30, "Sets passwords for new users to X days.")
185+
185186
}

0 commit comments

Comments
 (0)