cmd

package
v4.5.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

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

Index

Constants

View Source
const TreeBranch = "\t"
View Source
const TreeTrunk = "\t"

Variables

View Source
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
)
View Source
var (
	// Annotations contains the global annotations for a cluster
	Annotations []string

	// AnnotationsBackrest contains annotations specifc to pgBackRest
	AnnotationsBackrest []string

	// AnnotationsPgBouncer contains annotations specifc to pgBouncer
	AnnotationsPgBouncer []string

	// AnnotationsPostgres contains annotations specifc to PostgreSQL instances
	AnnotationsPostgres []string
)

group the annotation requests

View Source
var (
	// the resource requests / limits for PostgreSQL instances
	CPURequest, MemoryRequest string
	CPULimit, MemoryLimit     string
	// the resource requests / limits for the pgBackRest repository
	BackrestCPURequest, BackrestMemoryRequest string
	BackrestCPULimit, BackrestMemoryLimit     string
	// the resource requests / limits for pgBouncer instances
	PgBouncerCPURequest, PgBouncerMemoryRequest string
	PgBouncerCPULimit, PgBouncerMemoryLimit     string
	// the resource requests / limits for Crunchy Postgres Exporter the sidecar container
	ExporterCPURequest, ExporterMemoryRequest string
	ExporterCPULimit, ExporterMemoryLimit     string
)

group the various container resource requests together, i.e. for CPU/Memory

View Source
var (
	// TLSOnly indicates that only TLS connections will be accepted for a
	// PostgreSQL cluster
	TLSOnly bool
	// TLSSecret is the name of the secret that contains the TLS information for
	// enabling TLS in a PostgreSQL cluster
	TLSSecret string
	// ReplicationTLSSecret is the name of the secret that contains the TLS
	// information for enabling certificate-based authentication between instances
	// in a PostgreSQL cluster, particularly for replication
	ReplicationTLSSecret string
	// CASecret is the name of the secret that contains the CA information for
	// enabling TLS in a PostgreSQL cluster
	CASecret string
)

variables used for setting up TLS-enabled PostgreSQL clusters

View Source
var (
	// DisableLogin allows a user to disable the ability for a PostgreSQL uesr to
	// log in
	DisableLogin bool
	// EnableLogin allows a user to enable the ability for a PostgreSQL uesr to
	// log in
	EnableLogin bool
	// ExpireUser sets a user to having their password expired
	ExpireUser bool
	// PgoroleChangePermissions does something with the pgouser access controls,
	// I'm not sure but I wanted this at least to be documented
	PgoroleChangePermissions bool
	// RotatePassword is a flag that allows one to specify that a password be
	// automatically rotated, such as a service account type password
	RotatePassword bool
	// DisableStandby can be used to disable standby mode when enabled in an existing cluster
	DisableStandby bool
	// EnableStandby can be used to enable standby mode in an existing cluster
	EnableStandby bool
	// Shutdown is used to indicate that the cluster should be shutdown
	Shutdown bool
	// Startup is used to indicate that the cluster should be started (assuming it is shutdown)
	Startup bool
)
View Source
var APIServerURL string
View Source
var AllFlag bool
View Source
var AllNamespaces bool
View Source
var ArchiveFlag, DisableAutofailFlag, EnableAutofailFlag, PgbouncerFlag, MetricsFlag, BadgerFlag bool
View Source
var BackrestConfig string
View Source
var BackrestPVCSize string
View Source
var BackrestRepoPath string

BackrestRepoPath allows the pgBackRest repo path to be defined instead of using the default

View Source
var BackrestRestoreFrom string
View Source
var BackrestS3Bucket string
View Source
var BackrestS3CASecretName string

BackrestS3CASecretName, if provided, is the name of a secret to use that contains a CA certificate to use for the pgBackRest repo

View Source
var BackrestS3Endpoint string
View Source
var BackrestS3Key string
View Source
var BackrestS3KeySecret string
View Source
var BackrestS3Region string
View Source
var BackrestS3URIStyle string
View Source
var BackrestS3VerifyTLS bool
View Source
var BackrestStorageConfig, ReplicaStorageConfig, StorageConfig string
View Source
var BackrestStorageType string
View Source
var BackupOpts string
View Source
var BackupPath, BackupPVC string
View Source
var BackupType string
View Source
var CCPImage string
View Source
var CCPImagePrefix string
View Source
var CCPImageTag string
View Source
var ClientVersionOnly bool

ClientVersionOnly indicates that only the client version should be returned, not make a call to the server

View Source
var ClusterReplicaCount int
View Source
var ConfigMapName string

unused but coming soon to a theatre near you

View Source
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 pgadmin
    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
    * pgadmin
    * 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
    * pgadmin
    * pgbouncer
    * pgouser
    * pgorole
    * policy
    * namespace
    * user`)
			}
		}
	},
}
View Source
var CustomConfig string
View Source
var Database string
View Source
var DebugFlag bool
View Source
var DeleteData bool

flags used by more than 1 command

View Source
var DeleteLabel bool
View Source
var DryRun bool
View Source
var EXCLUDE_OS_TRUST bool
View Source
var Expired int

Expired expired flag

View Source
var GREEN func(a ...interface{}) string
View Source
var IgnoreValidation bool

IgnoreValidation stores the flag input value that determines whether image tag version checking should be done before allowing an upgrade to continue

View Source
var KeepBackups bool

KeepBackups, If set to "true", indicates that backups should be stored even after a cluster is deleted

View Source
var KeepData bool

KeepData, If set to "true", indicates that cluster data should be stored even after a cluster is deleted. This is DEPRECATED

View Source
var LabelCmdLabel string
View Source
var LabelMap map[string]string
View Source
var Labelselector string
View Source
var ManagedUser bool
View Source
var Namespace string
View Source
var NoPrompt bool

NoPrompt, If set to "true", indicates that the user should not be prompted before executing a delete command

View Source
var NodeLabel string
View Source
var OutputFormat string
View Source
var PGBackRestType string
View Source
var PGDumpDB string

PGDumpDB is used to store the name of the pgDump database when performing either a backup or restore

View Source
var PGOEventAddress string
View Source
var PGOImagePrefix string
View Source
var PGONamespace string
View Source
var PGO_CA_CERT, PGO_CLIENT_CERT, PGO_CLIENT_KEY string
View Source
var PGO_DISABLE_TLS bool
View Source
var PITRTarget string
View Source
var PVCName string
View Source
var PVCSize string
View Source
var Password string
View Source
var PasswordAgeDays int

PasswordAgeDays password age flag

View Source
var PasswordLength int

PasswordLength password length flag

View Source
var PasswordReplication string

PasswordReplication specifies the password for the cluster replication user

View Source
var PasswordSuperuser string

PasswordSuperuser specifies the password for the cluster superuser

View Source
var PasswordType string

PasswordType allows one to specify if the password should be MD5 or SCRAM we presently ensure it defaults to MD5

View Source
var PasswordValidAlways bool

PasswordValidAlways allows a user to explicitly set that their passowrd is always valid (i.e. no expiration time)

View Source
var Permissions string
View Source
var PgBouncerReplicas int32

PgBouncerReplicas is the total number of replica pods to deploy with a pgBouncer Deployment

View Source
var PgBouncerUninstall bool

PgBouncerUninstall is used to ensure the objects intalled in PostgreSQL on behalf of pgbouncer are either not applied (in the case of a cluster create) or are removed (in the case of a pgo delete pgbouncer)

View Source
var PgouserChangePassword bool
View Source
var PgouserPassword, PgouserRoles, PgouserNamespaces string
View Source
var PodAntiAffinity string
View Source
var PodAntiAffinityPgBackRest string
View Source
var PodAntiAffinityPgBouncer string
View Source
var PoliciesFlag, PolicyFile, PolicyURL string
View Source
var Query bool
View Source
var RED func(a ...interface{}) string
View Source
var ReplicaCount int
View Source
var RestoreFrom string
View Source
var RestoreType string
View Source
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

View Source
var Schedule string
View Source
var ScheduleDatabase string
View Source
var ScheduleName string
View Source
var ScheduleOptions string
View Source
var SchedulePolicy string
View Source
var ScheduleSecret string
View Source
var ScheduleType string
View Source
var Secret string
View Source
var SecretFrom string
View Source
var Selector string
View Source
var ServiceType string
View Source
var SessionCredentials msgs.BasicAuthCredentials

SessionCredentials stores the PGO user, PGO password and the PGO APIServer URL

View Source
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

View Source
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

View Source
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 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
	* cluster
	* config
	* pgadmin
	* pgbouncer
	* pgouser
	* policy
	* pvc
	* namespace
	* workflow
	* user
	`)
		} else {
			switch args[0] {
			case "backup", "cluster", "config", "pgadmin", "pgbouncer",
				"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
	* cluster
	* config
	* pgadmin
	* pgbouncer
	* pgouser
	* policy
	* pvc
	* namespace
	* workflow
	* user`)
			}
		}

	},
}
View Source
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)
	},
}
View Source
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)
	},
}
View Source
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)
		}
	},
}
View Source
var ShowPgAdminCmd = &cobra.Command{
	Use:   "pgadmin",
	Short: "Show pgadmin deployment information",
	Long: `Show service information about a pgadmin deployment. For example:

	pgo show pgadmin thecluster
	pgo show pgadmin --selector=app=theapp
	`,

	Run: func(cmd *cobra.Command, args []string) {
		if Namespace == "" {
			Namespace = PGONamespace
		}
		showPgAdmin(Namespace, args)
	},
}
View Source
var ShowPgBouncerCmd = &cobra.Command{
	Use:   "pgbouncer",
	Short: "Show pgbouncer deployment information",
	Long: `Show user, password, and service information about a pgbouncer deployment. For example:

	pgo show pgbouncer hacluster
	pgo show pgbouncer --selector=app=payment
	`,

	Run: func(cmd *cobra.Command, args []string) {
		if Namespace == "" {
			Namespace = PGONamespace
		}
		showPgBouncer(Namespace, args)
	},
}
View Source
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)
	},
}
View Source
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)
	},
}
View Source
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)
		}
	},
}
View Source
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

View Source
var ShowSystemAccounts bool

ShowSystemAccounts enables the display of the PostgreSQL user accounts that perform system functions, such as the "postgres" user

View Source
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

View Source
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)
	},
}
View Source
var Standby bool

Standby determines whether or not the cluster should be created as a standby cluster

View Source
var Summary bool
View Source
var SyncReplication bool
View Source
var Tablespaces []string
View Source
var Target string
View Source
var Targets []string
View Source
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 --disable-autofail
    pgo update cluster --selector=name=mycluster --disable-autofail
    pgo update cluster --all --enable-autofail`,
	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.")
			os.Exit(1)
		}

		if EnableAutofailFlag && DisableAutofailFlag {
			fmt.Println("Error: Cannot set --enable-autofail and --disable-autofail simultaneously")
			os.Exit(1)
		}

		if EnableStandby {
			fmt.Println("Enabling standby mode will result in the deltion of all PVCs " +
				"for this cluster!\nData will only be retained if the proper retention policy " +
				"is configured for any associated storage classes and/or persistent volumes.\n" +
				"Please proceed with caution.")
		}

		if DisableStandby {
			fmt.Println("Disabling standby mode will enable database writes for this " +
				"cluster.\nPlease ensure the cluster this standby cluster is replicating " +
				"from has been properly shutdown before proceeding!")
		}

		if len(Tablespaces) > 0 {
			fmt.Println("Adding tablespaces can cause downtime.")
		}

		if CPURequest != "" || CPULimit != "" {
			fmt.Println("Updating CPU resources can cause downtime.")
		}

		if MemoryRequest != "" || MemoryLimit != "" {
			fmt.Println("Updating memory resources can cause downtime.")
		}

		if BackrestCPURequest != "" || BackrestMemoryRequest != "" ||
			BackrestCPULimit != "" || BackrestMemoryLimit != "" {
			fmt.Println("Updating pgBackRest resources can cause temporary unavailability of backups and WAL archives.")
		}

		if ExporterCPURequest != "" || ExporterMemoryRequest != "" ||
			ExporterCPULimit != "" || ExporterMemoryLimit != "" {
			fmt.Println("Updating Crunchy Postgres Exporter resources can cause downtime.")
		}

		if !util.AskForConfirmation(NoPrompt, "") {
			fmt.Println("Aborting...")
			return
		}

		updateCluster(args, Namespace)
	},
}

UpdateClusterCmd ...

View Source
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 cluster --selector=name=mycluster --autofail=false
	pgo update cluster --all --autofail=true
	pgo update namespace mynamespace
	pgo update pgbouncer mycluster --rotate-password
	pgo update pgorole somerole --pgorole-permission="Cat"
	pgo update pgouser someuser --pgouser-password=somenewpassword
	pgo update pgouser someuser --pgouser-roles="role1,role2"
	pgo update pgouser someuser --pgouser-namespaces="pgouser2"
	pgo update pgorole somerole --pgorole-permission="Cat"
	pgo update user mycluster --username=testuser --selector=name=mycluster --password=somepassword`,
	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:
	* cluster
	* namespace
	* pgbouncer
	* pgorole
	* pgouser
	* user`)
		} else {
			switch args[0] {
			case "user", "cluster", "pgbouncer", "pgouser", "pgorole", "namespace":
				break
			default:
				fmt.Println(`Error: You must specify the type of resource to update.  Valid resource types include:
	* cluster
	* namespace
	* pgbouncer
	* pgorole
	* pgouser
	* user`)
			}
		}

	},
}

UpdateCmd represents the update command

View Source
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)
		}
	},
}
View Source
var UpdatePgBouncerCmd = &cobra.Command{
	Use:   "pgbouncer",
	Short: "Update a pgBouncer deployment for a PostgreSQL cluster",
	Long: `Used to update the pgBouncer deployment for a PostgreSQL cluster, such
	as by rotating a password. For example:

	pgo update pgbouncer hacluster --rotate-password
	`,

	Run: func(cmd *cobra.Command, args []string) {
		if !util.AskForConfirmation(NoPrompt, pgBouncerPrompt) {
			fmt.Println("Aborting...")
			return
		}

		if Namespace == "" {
			Namespace = PGONamespace
		}

		if PgBouncerReplicas < 0 {
			fmt.Println("Error: You must specify one or more replicas.")
			os.Exit(1)
		}

		updatePgBouncer(Namespace, args)
	},
}
View Source
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)
		}
	},
}
View Source
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)
		}
	},
}
View Source
var UpdateUserCmd = &cobra.Command{
	Use:   "user",
	Short: "Update a PostgreSQL user",
	Long: `Allows the ability to perform various user management functions for PostgreSQL users.

For example:

//change a password, set valid days for 40 days from now
pgo update user mycluster --username=someuser --password=foo
//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

# Disable the ability for a user to log into the PostgreSQL cluster
pgo update user mycluster --username=foobar --disable-login

# Enable the ability for a user to log into the PostgreSQL cluster
pgo update user mycluster --username=foobar --enable-login
		`,
	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.")
			os.Exit(1)
		}

		if Username == "" && Expired == 0 {
			fmt.Println("Error: You must specify either --username or --expired")
			os.Exit(1)
		}

		if EnableLogin && DisableLogin {
			fmt.Println("Error: Cannot set --enable-login and --disable-login simultaneously")
			os.Exit(1)
		}

		updateUser(args, Namespace)
	},
}
View Source
var UpgradeCCPImageTag string

UpgradeCCPImageTag stores the image tag for the cluster being upgraded. This is specifically required when upgrading PostGIS clusters because that tag will necessarily differ from the other images tags due to the inclusion of the PostGIS version.

View Source
var UpgradeCmd = &cobra.Command{
	Use:   "upgrade",
	Short: "Perform a cluster upgrade.",
	Long: `UPGRADE allows you to perform a comprehensive PGCluster upgrade 
	(for use after performing a Postgres Operator upgrade). 
	For example:
	
	pgo upgrade mycluster
	Upgrades the cluster for use with the upgraded Postgres Operator version.`,
	Run: func(cmd *cobra.Command, args []string) {
		log.Debug("cluster upgrade called")
		if Namespace == "" {
			Namespace = PGONamespace
		}
		if len(args) == 0 && Selector == "" {
			fmt.Println(`Error: You must specify the cluster to upgrade.`)
		} else {
			fmt.Println("All active replicas will be scaled down and the primary database in this cluster will be stopped and recreated as part of this workflow!")
			if util.AskForConfirmation(NoPrompt, "") {
				createUpgrade(args, Namespace)
			} else {
				fmt.Println("Aborting...")
			}
		}
	},
}
View Source
var UserLabels string
View Source
var Username string

Username is a postgres username

View Source
var WALPVCSize string
View Source
var WALStorageConfig string
View Source
var YELLOW func(a ...interface{}) string

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

func GetTLSTransport() (*http.Transport, error)

GetTLSTransport returns an http.Transport configured with environmental TLS client settings

func NewAPIClient

func NewAPIClient() *http.Client

NewAPIClient returns an http client configured with a tls.Config based on environmental settings and a default timeout

func NewAPIClientTLS

func NewAPIClientTLS() (*http.Client, error)

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

func StatusCheck

func StatusCheck(resp *http.Response)

StatusCheck ...

Types

type TailHandler

type TailHandler struct {
	// contains filtered or unexported fields
}

func (*TailHandler) HandleMessage

func (th *TailHandler) HandleMessage(m *nsq.Message) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL