 Documentation
      ¶
      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 ¶
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 ( // the source cluster used for the clone, e.g. "oldcluster" SourceClusterName string // the target/destination cluster used for the clone, e.g. "newcluster" TargetClusterName string // BackrestStorageSource represents the data source to use (e.g. s3 or local) when both s3 // and local are enabled in the cluster being cloned BackrestStorageSource string )
var APIServerURL string
    var AllFlag bool
    var AllNamespaces bool
    var ArchiveFlag, DisableAutofailFlag, PgbouncerFlag, MetricsFlag, BadgerFlag bool
    var BackrestRestoreFrom string
    var BackrestS3Bucket string
    var BackrestS3Endpoint string
    var BackrestS3Key string
    var BackrestS3KeySecret string
    var BackrestS3Region 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 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 * pgouser * pgorole * policy * namespace * user`) } else { switch args[0] { case "cluster", "pgbouncer", "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 * pgouser * pgorole * policy * namespace * user`) } } }, }
var CustomConfig string
    var DebugFlag 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 EXCLUDE_OS_TRUST bool
    var ExpireUser bool
    var Expired string
    Expired expired flag
var GREEN func(a ...interface{}) string
    var KeepBackups bool
    KeepBackups, If set to "true", indicates that backups should be stored even after a cluster is deleted
var KeepData bool
    KeepData, If set to "true", indicates that cluster data should be stored even after a cluster is deleted. This is DEPRECATED
var LabelCmdLabel string
    var LabelMap map[string]string
    var Labelselector string
    var LoadConfig string
    var ManagedUser bool
    var Namespace string
    var NoPrompt bool
    NoPrompt, If set to "true", indicates that the user should not be prompted before executing a delete command
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 PGO_DISABLE_TLS bool
    var PITRTarget string
    var PVCName 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 PodAntiAffinity string
    var PoliciesFlag, PolicyFile, PolicyURL string
    var Query bool
    var RED func(a ...interface{}) string
    var ReplicaCount int
    var ReplicaStorageConfig, StorageConfig 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
    SessionCredentials stores the PGO user, PGO password and the PGO APIServer URL
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_BACKREST { showBackrest(args, Namespace) } else if showBackupType == config.LABEL_BACKUP_TYPE_PGDUMP { showpgDump(args, Namespace) } else { fmt.Println("Error: Valid backup-type values are pgbackrest and pgdump. The default if not supplied is pgbackrest.") } } }, }
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 ShowPVCCmd = &cobra.Command{ Use: "pvc", Short: "Show PVC information for a cluster", Long: `Show PVC information. For example: pgo show pvc mycluster pgo show pvc --all`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 && !AllFlag { fmt.Println("Error: Cluster 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 SyncReplication 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 --pgouser-roles=somerole pgo update pgouser myuser --pgouser-password=somepassword --pgouser-roles=somerole pgo update pgouser myuser --pgouser-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, set valid days for 40 days from now pgo update user mycluster --username=someuser --password=foo --valid-days=40 //expire password for a user pgo update user mycluster --username=someuser --expire-user //Update all passwords older than the number of days specified pgo update user mycluster --expired=45 --password-length=8`, Run: func(cmd *cobra.Command, args []string) { validDaysUpdate := cmd.Flag("valid-days").Changed 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, validDaysUpdate) } }, }
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 GetTLSTransport ¶
GetTLSTransport returns an http.Transport configured with environmental TLS client settings
func NewAPIClient ¶
NewAPIClient returns an http client configured with a tls.Config based on environmental settings and a default timeout
func NewAPIClientTLS ¶
NewAPIClientTLS returns an http client configured with a tls.Config based on environmental settings and a default timeout It returns an error if required environmental settings are missing
func SetSessionUserCredentials ¶
func SetSessionUserCredentials()
SetSessionUserCredentials gathers the pgouser and password information and stores them for use by the PGO client
Types ¶
type TailHandler ¶
type TailHandler struct {
	// contains filtered or unexported fields
}
    func (*TailHandler) HandleMessage ¶
func (th *TailHandler) HandleMessage(m *nsq.Message) error
       Source Files
      ¶
      Source Files
      ¶
    
- auth.go
- backrest.go
- backup.go
- benchmark.go
- cat.go
- clone.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
- 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