postgresql

package
v0.0.0-...-f588f65 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBKey         = "database"
	DBUsernameKey = "username"
	DBPasswordKey = "password"
)

Variables

This section is empty.

Functions

func AdminRoleSecretName

func AdminRoleSecretName(instanceName string) string

func IsMaster

func IsMaster(pod *corev1.Pod) bool

func MasterService

func MasterService(instanceName string) string

func NewK8sClient

func NewK8sClient(kubeconfig string) (runtimeClient.Client, error)

func PatroniService

func PatroniService(instanceName string) string

func PvcName

func PvcName(instanceName string, index int) string

func StandbyRoleSecretName

func StandbyRoleSecretName(instanceName string) string

func WithVolumeSize

func WithVolumeSize(s string) func(*Postgresql)

Types

type Client

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

Client is responsible for opening up connections to the DSI in order to test the dataservice's behavior. Connections are opened for each method call to ensure a new and untainted connection to the database. This is important since leaving a connection open would break restore functionality.

func NewClient

func NewClient(credentials map[string]string, host string, port string, sslmode string) Client

func NewClientOverPortForwarding

func NewClientOverPortForwarding(credentials map[string]string, port string) Client

func (Client) CheckParameter

func (c Client) CheckParameter(ctx context.Context, parameter, expectedValue string) error

func (Client) CollectionExists

func (c Client) CollectionExists(ctx context.Context, collection string) bool

func (Client) Delete

func (c Client) Delete(ctx context.Context, entity, data string) error

func (Client) Read

func (c Client) Read(ctx context.Context, tableName string) (string, error)

func (Client) UserExists

func (c Client) UserExists(ctx context.Context, username string) (bool, error)

func (Client) Write

func (c Client) Write(ctx context.Context, tableName, data string) error

type Postgresql

type Postgresql struct {
	*pgv1beta3.Postgresql
}

func New

func New(namespace, name string, replicas int32, opts ...func(*Postgresql)) *Postgresql

func NewEmpty

func NewEmpty() Postgresql

func (Postgresql) AddPreferredPodAntiAffinityTerm

func (pg Postgresql) AddPreferredPodAntiAffinityTerm(weight int, at corev1.PodAffinityTerm)

func (Postgresql) AddRequiredPodAntiAffinityTerm

func (pg Postgresql) AddRequiredPodAntiAffinityTerm(at corev1.PodAffinityTerm)

func (Postgresql) CheckPatroniLabelsAssigned

func (pg Postgresql) CheckPatroniLabelsAssigned(ctx context.Context,
	c runtimeClient.Client,
) (bool, error)

func (Postgresql) ClusterStatus

func (pg Postgresql) ClusterStatus() string

func (Postgresql) GetClientObject

func (pg Postgresql) GetClientObject() runtimeClient.Object

GetClientObject exposes the embedded PostgreSQL object to methods/functions that expect that type. We also need to set the APIVersion and Kind since Kubernetes will remove these fields when marshalling API objects.

func (Postgresql) GetMasterLabels

func (pg Postgresql) GetMasterLabels() map[string]string

func (Postgresql) GetReplicaLabels

func (pg Postgresql) GetReplicaLabels() map[string]string

func (Postgresql) Pods

func (pg Postgresql) Pods(ctx context.Context,
	k8sClient runtimeClient.Client,
) ([]corev1.Pod, error)

Pods uses `k8sClient` to retrieve all the pods that belong to `pg`. The retrieval is based entirely on metadata labels, and doesn't check whether the pods actually belong to `pg` or to an older DSI with same namespace, name and kind. TODO: Improve robustness by checking that the pods actually belong to DSI.

func (Postgresql) SetTolerations

func (pg Postgresql) SetTolerations(ts ...corev1.Toleration)

func (Postgresql) StatefulSet

func (pg Postgresql) StatefulSet(ctx context.Context,
	k8sClient runtimeClient.Client,
) (*appsv1.StatefulSet, error)

TODO: make the K8s client a field of pg rather than something to pass to its functions.

Jump to

Keyboard shortcuts

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