Documentation ¶
Overview ¶
Package cmd provides the command line functions of the crunchy CLI
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI ¶
Package cmd provides the command line functions of the crunchy CLI
Index ¶
Constants ¶
const CAPMAX = 50
const TreeBranch = "\t"
const TreeTrunk = "\t"
Variables ¶
var ( BenchmarkClients int BenchmarkJobs int BenchmarkScale int BenchmarkTransactions int BenchmarkDatabase string BenchmarkInitOpts string BenchmarkOpts string BenchmarkPolicy string BenchmarkUser string )
var APIServerURL string
var AllFlag bool
var AllNamespaces bool
var ArchiveFlag, AutofailFlag, PgpoolFlag, PgbouncerFlag, MetricsFlag, BadgerFlag bool
var AutofailReplaceReplica string
var BackrestFlag, BackrestRestoreFrom string
var BackrestStorageType string
var BackupOpts string
var BackupPath, BackupPVC string
var BackupType string
var CCPImage string
var CCPImageTag string
var ClusterReplicaCount int
var ConfigMapName string
unused but coming soon to a theatre near you
var ContainerResources string
var CreateCmd = &cobra.Command{ Use: "create", Short: "Create a Postgres Operator resource", Long: `CREATE allows you to create a new Operator resource. For example: pgo create cluster pgo create pgbouncer pgo create pgpool pgo create pgouser pgo create pgorole pgo create policy pgo create namespace pgo create user`, Run: func(cmd *cobra.Command, args []string) { log.Debug("create called") if len(args) == 0 { fmt.Println(`Error: You must specify the type of resource to create. Valid resource types include: * cluster * pgbouncer * pgpool * pgouser * pgorole * policy * namespace * user`) } else { switch args[0] { case "cluster", "pgbouncer", "pgpool", "pgouser", "pgorole", "policy", "user", "namespace": break default: fmt.Println(`Error: You must specify the type of resource to create. Valid resource types include: * cluster * pgbouncer * pgpool * pgouser * pgorole * policy * namespace * user`) } } }, }
var CustomConfig string
var DebugFlag bool
var DeleteBackups bool
var DeleteData bool
flags used by more than 1 command
var DeleteLabel bool
var DeleteUser string
DeleteUser delete user flag
var DryRun bool
var ExpireUser bool
var Expired string
Expired expired flag
var GREEN func(a ...interface{}) string
var LabelCmdLabel string
var LabelMap map[string]string
var Labelselector string
var LoadConfig string
var ManagedUser bool
var Namespace string
var NoPrompt bool
var NodeLabel string
var OutputFormat string
var PGBackRestType string
var PGOEventAddress string
var PGONamespace string
var PGO_CA_CERT, PGO_CLIENT_CERT, PGO_CLIENT_KEY string
var PITRTarget, RestoreBackupPath string
var PVCName string
var PVCRoot string
var Password string
var PasswordAgeDays int
PasswordAgeDays password age flag
var PasswordLength int
PasswordLength password length flag
var Permissions string
var PgBouncerPassword string
var PgBouncerUser string
var PgbouncerSecret string
var PgoroleChangePermissions bool
var PgouserChangePassword bool
var PgouserPassword, PgouserRoles, PgouserNamespaces string
var PgpoolSecret string
var PoliciesFlag, PolicyFile, PolicyURL string
var Query bool
var RED func(a ...interface{}) string
var ReplicaCount int
var ReplicaStorageConfig, StorageConfig string
var RestoreToPVC string
var RestoreType string
var RootCmd = &cobra.Command{
Use: "pgo",
Short: "The pgo command line interface.",
Long: `The pgo command line interface lets you create and manage PostgreSQL clusters.`,
}
RootCmd represents the base command when called without any subcommands
var Schedule string
var ScheduleDatabase string
var ScheduleName string
var ScheduleOptions string
var SchedulePolicy string
var ScheduleSecret string
var ScheduleType string
var Secret string
var SecretFrom string
var Selector string
var Series int
var ServiceType string
var SessionCredentials msgs.BasicAuthCredentials
var ShowBackupCmd = &cobra.Command{ Use: "backup", Short: "Show backup information", Long: `Show backup information. For example: pgo show backup mycluser`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 { fmt.Println("Error: cluster name(s) required for this command.") } else { if showBackupType == "" || showBackupType == config.LABEL_BACKUP_TYPE_BASEBACKUP { showBackup(args, Namespace) } else if showBackupType == config.LABEL_BACKUP_TYPE_BACKREST { showBackrest(args, Namespace) } else if showBackupType == config.LABEL_BACKUP_TYPE_PGDUMP { showpgDump(args, Namespace) } else { fmt.Println("Error: Valid backup-type values are pgbasebackup, pgbackrest and pgdump. The default if not supplied is pgbasebackup.") } } }, }
showBackupCmd represents the show backup command
var ShowBenchmarkCmd = &cobra.Command{ Use: "benchmark", Short: "Show benchmark information", Long: `Show benchmark results for clusters. For example: pgo show benchmark mycluster pgo show benchmark --selector=pg-cluster=mycluster`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 && Selector == "" { fmt.Println("Error: cluster name or selector are required to show benchmark results.") return } showBenchmark(args, Namespace) }, }
ShowBenchmarkCmd represents the show benchmark command
var ShowClusterCmd = &cobra.Command{ Use: "cluster", Short: "Show cluster information", Long: `Show a PostgreSQL cluster. For example: pgo show cluster --all pgo show cluster mycluster`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if Selector == "" && len(args) == 0 && !AllFlag { fmt.Println("Error: Cluster name(s), --selector, or --all required for this command.") } else { showCluster(args, Namespace) } }, }
ShowClusterCmd represents the show cluster command
var ShowCmd = &cobra.Command{ Use: "show", Short: "Show the description of a cluster", Long: `Show allows you to show the details of a policy, backup, pvc, or cluster. For example: pgo show backup mycluster pgo show backup mycluster --backup-type=pgbackrest pgo show benchmark mycluster pgo show cluster mycluster pgo show config pgo show pgouser someuser pgo show policy policy1 pgo show pvc mycluster pgo show namespace pgo show workflow 25927091-b343-4017-be4b-71575f0b3eb5 pgo show user --selector=name=mycluster`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { fmt.Println(`Error: You must specify the type of resource to show. Valid resource types include: * backup * benchmark * cluster * config * pgouser * policy * pvc * namespace * workflow * user `) } else { switch args[0] { case "backup", "benchmark", "cluster", "config", "pgouser", "policy", "pvc", "schedule", "namespace", "workflow", "user": break default: fmt.Println(`Error: You must specify the type of resource to show. Valid resource types include: * backup * benchmark * cluster * config * pgouser * policy * pvc * namespace * workflow * user`) } } }, }
var ShowConfigCmd = &cobra.Command{ Use: "config", Short: "Show configuration information", Long: `Show configuration information for the Operator. For example: pgo show config`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } showConfig(args, Namespace) }, }
var ShowNamespaceCmd = &cobra.Command{ Use: "namespace", Short: "Show namespace information", Long: `Show namespace information for the Operator. For example: pgo show namespace`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } showNamespace(args) }, }
var ShowPVC bool
var ShowPVCCmd = &cobra.Command{ Use: "pvc", Short: "Show PVC information", Long: `Show PVC information. For example: pgo show pvc mycluster pgo show pvc --all pgo show pvc mycluster-backup pgo show pvc mycluster-xlog pgo show pvc a2-backup --pvc-root=a2-backups/2019-01-12-17-09-42`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 && !AllFlag { fmt.Println("Error: PVC name(s) or --all required for this command.") } else { if Namespace == "" { Namespace = PGONamespace } showPVC(args, Namespace) } }, }
var ShowPgoroleCmd = &cobra.Command{ Use: "pgorole", Short: "Show pgorole information", Long: `Show pgorole information . For example: pgo show pgorole somerole`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } showPgorole(args, Namespace) }, }
var ShowPgouserCmd = &cobra.Command{ Use: "pgouser", Short: "Show pgouser information", Long: `Show pgouser information for an Operator user. For example: pgo show pgouser someuser`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } showPgouser(args, Namespace) }, }
var ShowPolicyCmd = &cobra.Command{ Use: "policy", Short: "Show policy information", Long: `Show policy information. For example: pgo show policy --all pgo show policy policy1`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 && !AllFlag { fmt.Println("Error: Policy name(s) or --all required for this command.") } else { if Namespace == "" { Namespace = PGONamespace } showPolicy(args, Namespace) } }, }
var ShowScheduleCmd = &cobra.Command{ Use: "schedule", Short: "Show schedule information", Long: `Show cron-like schedules. For example: pgo show schedule mycluster pgo show schedule --selector=pg-cluster=mycluster pgo show schedule --schedule-name=mycluster-pgbackrest-full`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 && Selector == "" && ScheduleName == "" { fmt.Println("Error: cluster name, schedule name or selector is required to show a schedule.") return } showSchedule(args, Namespace) }, }
ShowScheduleCmd represents the show schedule command
var ShowUserCmd = &cobra.Command{ Use: "user", Short: "Show user information", Long: `Show users on a cluster. For example: pgo show user --all pgo show user mycluster pgo show user --selector=name=nycluster`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if Selector == "" && AllFlag == false && len(args) == 0 { fmt.Println("Error: --selector, --all, or cluster name()s required for this command") } else { showUser(args, Namespace) } }, }
ShowUserCmd represents the show user command
var ShowWorkflowCmd = &cobra.Command{ Use: "workflow", Short: "Show workflow information", Long: `Show workflow information for a given workflow. For example: pgo show workflow 25927091-b343-4017-be4b-71575f0b3eb5`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } showWorkflow(args, Namespace) }, }
var Summary bool
var Target string
var UpdateClusterCmd = &cobra.Command{ Use: "cluster", Short: "Update a PostgreSQL cluster", Long: `Update a PostgreSQL cluster. For example: pgo update cluster mycluster --autofail=false pgo update cluster mycluster myothercluster --autofail=false pgo update cluster --selector=name=mycluster --autofail=false pgo update cluster --all --autofail=true`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 && Selector == "" && !AllFlag { fmt.Println("Error: A cluster name(s) or selector or --all is required for this command.") } else { if util.AskForConfirmation(NoPrompt, "") { updateCluster(args, Namespace) } else { fmt.Println("Aborting...") } } }, }
UpdateClusterCmd ...
var UpdateCmd = &cobra.Command{ Use: "update", Short: "Update a pgouser, pgorole, or cluster", Long: `The update command allows you to update a pgouser, pgorole, or cluster. For example: pgo update pgouser someuser --pgouser-password=somenewpassword pgo update pgouser someuser --pgouser-roles="role1,role2" pgo update pgouser someuser --pgouser-namespaces="pgouser2" pgo update user mycluster --username=testuser --selector=name=mycluster --password=somepassword pgo update pgorole somerole --pgorole-permission="Cat" pgo update namespace mynamespace pgo update cluster --selector=name=mycluster --autofail=false pgo update cluster --all --autofail=true`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { fmt.Println(`Error: You must specify the type of resource to update. Valid resource types include: * pgouser * pgorole * user * namespace * cluster`) } else { switch args[0] { case "user", "cluster", "pgouser", "pgorole", "namespace": break default: fmt.Println(`Error: You must specify the type of resource to update. Valid resource types include: * cluster * pgorole * user * namespace * pgouser`) } } }, }
UpdateCmd represents the update command
var UpdateNamespaceCmd = &cobra.Command{ Use: "namespace", Short: "Update a namespace, applying Operator RBAC", Long: `UPDATE allows you to update a Namespace. For example: pgo update namespace mynamespace`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { fmt.Println("Error: You must specify the name of a Namespace.") } else { updateNamespace(args) } }, }
var UpdatePgoroleCmd = &cobra.Command{ Use: "pgorole", Short: "Update a pgorole", Long: `UPDATE allows you to update a pgo role. For example: pgo update pgorole somerole --permissions="Cat,Ls`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 { fmt.Println("Error: You must specify the name of a pgorole.") } else { updatePgorole(args, Namespace) } }, }
var UpdatePgouserCmd = &cobra.Command{ Use: "pgouser", Short: "Update a pgouser", Long: `UPDATE allows you to update a pgo user. For example: pgo update pgouser myuser --change-password pgo update pgouser myuser --change-password --password=somepassword --no-prompt`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if len(args) == 0 { fmt.Println("Error: You must specify the name of a pgouser.") } else { updatePgouser(args, Namespace) } }, }
var UpdateUserCmd = &cobra.Command{ Use: "user", Short: "Update a postgres user", Long: `UPDATE allows you to update a pgo user. For example: //change a password pgo update user mycluster --username=someuser --password=foo --update-passwords --expired=200 //expire password for a user pgo update user mycluster --username=someuser --expire-user`, Run: func(cmd *cobra.Command, args []string) { if Namespace == "" { Namespace = PGONamespace } if !AllFlag && Selector == "" && len(args) == 0 { fmt.Println("Error: You must specify a --selector, --all or a list of clusters.") } else { updateUser(args, Namespace) } }, }
var UserLabels string
var Username string
Username is a postgres username
var ValidDays string
ValidDays valid days flag
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GetCredentials ¶
func GetCredentials()
func GetCredentialsFromEnvironment ¶
func GetCredentialsFromEnvironment() msgs.BasicAuthCredentials
func GetCredentialsFromFile ¶
func GetCredentialsFromFile() msgs.BasicAuthCredentials
func UserHomeDir ¶
func UserHomeDir() string
Types ¶
type TailHandler ¶
type TailHandler struct {
// contains filtered or unexported fields
}
func (*TailHandler) HandleMessage ¶
func (th *TailHandler) HandleMessage(m *nsq.Message) error
Source Files ¶
- auth.go
- backrest.go
- backup.go
- benchmark.go
- cat.go
- cluster.go
- config.go
- create.go
- delete.go
- df.go
- failover.go
- flags.go
- label.go
- load.go
- ls.go
- namespace.go
- pgbouncer.go
- pgdump.go
- pgorole.go
- pgouser.go
- pgpool.go
- policy.go
- pvc.go
- reload.go
- restore.go
- root.go
- scale.go
- scaledown.go
- schedule.go
- show.go
- status.go
- test.go
- update.go
- upgrade.go
- user.go
- version.go
- watch.go
- workflow.go