cnpg

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BarmanCloudPluginName = "barman-cloud.cloudnative-pg.io"

BarmanCloudPluginName is the CNPG-I plugin name of the barman-cloud plugin, which supersedes the deprecated in-tree barman WAL archiving support.

Variables

This section is empty.

Functions

func IsClusterReady added in v0.0.2

func IsClusterReady(cluster *apiv1.Cluster) bool

Types

type Client

type Client struct {
	helpers.SimpleResourceLabeler
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *rest.Config) (*Client, error)

func (*Client) CreateBackup

func (cnpgc *Client) CreateBackup(ctx *contexts.Context, namespace, backupName, clusterName string, opts CreateBackupOptions) (*apiv1.Backup, error)

func (*Client) CreateCluster

func (cnpgc *Client) CreateCluster(ctx *contexts.Context, namespace, clusterName string,
	volumeSize resource.Quantity, servingCertificateSecretName, clientCASecretName, replicationUserCertName string,
	opts CreateClusterOptions) (*apiv1.Cluster, error)

Create a cluster for backup/recovery purposes specifically. Not intended for use general use. The created cluster should not be used by applications. Created cluster contains a single database server instance. Cluster can optionally be created from a backup. TLS authentication is required.

func (*Client) DeleteBackup

func (cnpgc *Client) DeleteBackup(ctx *contexts.Context, namespace, name string) error

func (*Client) DeleteCluster

func (cnpgc *Client) DeleteCluster(ctx *contexts.Context, namespace, name string) error

func (*Client) GetCluster

func (cnpgc *Client) GetCluster(ctx *contexts.Context, namespace, name string) (*apiv1.Cluster, error)

func (*Client) WaitForClusterDeleted added in v0.0.13

func (cnpgc *Client) WaitForClusterDeleted(ctx *contexts.Context, namespace, name string, opts WaitForClusterDeletedOpts) (err error)

WaitForClusterDeleted blocks until the named cluster no longer exists, or the timeout elapses. It is used after DeleteCluster when a cluster must be recreated under the same name (the recovery fallback), since CNPG cluster deletion is asynchronous (finalizers tear down pods/PVCs first).

func (*Client) WaitForReadyBackup

func (cnpgc *Client) WaitForReadyBackup(ctx *contexts.Context, namespace, name string, opts WaitForReadyBackupOpts) (backup *apiv1.Backup, err error)

func (*Client) WaitForReadyCluster

func (cnpgc *Client) WaitForReadyCluster(ctx *contexts.Context, namespace, name string, opts WaitForReadyClusterOpts) (cluster *apiv1.Cluster, err error)

type ClientInterface

type ClientInterface interface {
	helpers.ResourceLabeler
	// Backups
	CreateBackup(ctx *contexts.Context, namespace, backupName, clusterName string, opts CreateBackupOptions) (*apiv1.Backup, error)
	WaitForReadyBackup(ctx *contexts.Context, namespace, name string, opts WaitForReadyBackupOpts) (*apiv1.Backup, error)
	DeleteBackup(ctx *contexts.Context, namespace, name string) error
	// Clusters
	CreateCluster(ctx *contexts.Context, namespace, clusterName string, volumeSize resource.Quantity, servingCertificateSecretName, clientCASecretName, replicationUserCertName string, opts CreateClusterOptions) (*apiv1.Cluster, error)
	WaitForReadyCluster(ctx *contexts.Context, namespace, name string, opts WaitForReadyClusterOpts) (*apiv1.Cluster, error)
	GetCluster(ctx *contexts.Context, namespace, name string) (*apiv1.Cluster, error)
	DeleteCluster(ctx *contexts.Context, namespace, name string) error
	WaitForClusterDeleted(ctx *contexts.Context, namespace, name string, opts WaitForClusterDeletedOpts) error
}

type CreateBackupOptions

type CreateBackupOptions struct {
	helpers.GenerateName
	Method *apiv1.BackupMethod
	Target *apiv1.BackupTarget
}

type CreateClusterOptions

type CreateClusterOptions struct {
	helpers.GenerateName
	// Deprecated: BackupName recovers the new cluster from a CNPG Backup object
	// (bootstrap.recovery.backup). This relies on the deprecated in-tree barman WAL archiving
	// support to fetch WAL during recovery. For source clusters using the barman-cloud plugin,
	// use VolumeSnapshotRecovery instead. Mutually exclusive with VolumeSnapshotRecovery.
	BackupName string
	// VolumeSnapshotRecovery recovers the new cluster from volume snapshots, fetching WAL from an
	// external cluster. Mutually exclusive with BackupName.
	VolumeSnapshotRecovery *VolumeSnapshotRecovery
	RecoveryTarget         *apiv1.RecoveryTarget // Only valid if recovering from a backup or volume snapshots
	DatabaseName           string
	OwnerName              string
	StorageClass           string
	ResourceRequirements   corev1.ResourceRequirements
	ImageName              string
}

This doesn't need to support every option - just the ones that may be relavent to backups.

type KubernetesSecretCredentials

type KubernetesSecretCredentials struct {
	Host                         string
	Port                         string
	User                         string // TODO maybe pull this from client cert CN
	ServingCertificateCAFilePath string // Must be PEM encoded
	ClientCertificateFilePath    string // Must be PEM encoded
	ClientPrivateKeyFilePath     string // Must be PEM encoded
}

func (*KubernetesSecretCredentials) GetHost

func (ksc *KubernetesSecretCredentials) GetHost() string

func (*KubernetesSecretCredentials) GetPort

func (ksc *KubernetesSecretCredentials) GetPort() string

func (*KubernetesSecretCredentials) GetUsername

func (ksc *KubernetesSecretCredentials) GetUsername() string

func (*KubernetesSecretCredentials) GetVariables

type MockClientInterface

type MockClientInterface struct {
	mock.Mock
}

MockClientInterface is an autogenerated mock type for the ClientInterface type

func NewMockClientInterface

func NewMockClientInterface(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockClientInterface

NewMockClientInterface creates a new instance of MockClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockClientInterface) CreateBackup

func (_m *MockClientInterface) CreateBackup(ctx *contexts.Context, namespace string, backupName string, clusterName string, opts CreateBackupOptions) (*v1.Backup, error)

CreateBackup provides a mock function with given fields: ctx, namespace, backupName, clusterName, opts

func (*MockClientInterface) CreateCluster

func (_m *MockClientInterface) CreateCluster(ctx *contexts.Context, namespace string, clusterName string, volumeSize resource.Quantity, servingCertificateSecretName string, clientCASecretName string, replicationUserCertName string, opts CreateClusterOptions) (*v1.Cluster, error)

CreateCluster provides a mock function with given fields: ctx, namespace, clusterName, volumeSize, servingCertificateSecretName, clientCASecretName, replicationUserCertName, opts

func (*MockClientInterface) DeleteBackup

func (_m *MockClientInterface) DeleteBackup(ctx *contexts.Context, namespace string, name string) error

DeleteBackup provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) DeleteCluster

func (_m *MockClientInterface) DeleteCluster(ctx *contexts.Context, namespace string, name string) error

DeleteCluster provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) EXPECT

func (*MockClientInterface) GetCluster

func (_m *MockClientInterface) GetCluster(ctx *contexts.Context, namespace string, name string) (*v1.Cluster, error)

GetCluster provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) SetCommonLabels added in v0.0.9

func (_m *MockClientInterface) SetCommonLabels(labels map[string]string)

SetCommonLabels provides a mock function with given fields: labels

func (*MockClientInterface) WaitForClusterDeleted added in v0.0.13

func (_m *MockClientInterface) WaitForClusterDeleted(ctx *contexts.Context, namespace string, name string, opts WaitForClusterDeletedOpts) error

WaitForClusterDeleted provides a mock function with given fields: ctx, namespace, name, opts

func (*MockClientInterface) WaitForReadyBackup

func (_m *MockClientInterface) WaitForReadyBackup(ctx *contexts.Context, namespace string, name string, opts WaitForReadyBackupOpts) (*v1.Backup, error)

WaitForReadyBackup provides a mock function with given fields: ctx, namespace, name, opts

func (*MockClientInterface) WaitForReadyCluster

func (_m *MockClientInterface) WaitForReadyCluster(ctx *contexts.Context, namespace string, name string, opts WaitForReadyClusterOpts) (*v1.Cluster, error)

WaitForReadyCluster provides a mock function with given fields: ctx, namespace, name, opts

type MockClientInterface_CreateBackup_Call

type MockClientInterface_CreateBackup_Call struct {
	*mock.Call
}

MockClientInterface_CreateBackup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateBackup'

func (*MockClientInterface_CreateBackup_Call) Return

func (*MockClientInterface_CreateBackup_Call) Run

func (*MockClientInterface_CreateBackup_Call) RunAndReturn

type MockClientInterface_CreateCluster_Call

type MockClientInterface_CreateCluster_Call struct {
	*mock.Call
}

MockClientInterface_CreateCluster_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateCluster'

func (*MockClientInterface_CreateCluster_Call) Return

func (*MockClientInterface_CreateCluster_Call) Run

func (_c *MockClientInterface_CreateCluster_Call) Run(run func(ctx *contexts.Context, namespace string, clusterName string, volumeSize resource.Quantity, servingCertificateSecretName string, clientCASecretName string, replicationUserCertName string, opts CreateClusterOptions)) *MockClientInterface_CreateCluster_Call

type MockClientInterface_DeleteBackup_Call

type MockClientInterface_DeleteBackup_Call struct {
	*mock.Call
}

MockClientInterface_DeleteBackup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteBackup'

func (*MockClientInterface_DeleteBackup_Call) Return

func (*MockClientInterface_DeleteBackup_Call) Run

func (*MockClientInterface_DeleteBackup_Call) RunAndReturn

type MockClientInterface_DeleteCluster_Call

type MockClientInterface_DeleteCluster_Call struct {
	*mock.Call
}

MockClientInterface_DeleteCluster_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteCluster'

func (*MockClientInterface_DeleteCluster_Call) Return

func (*MockClientInterface_DeleteCluster_Call) Run

func (*MockClientInterface_DeleteCluster_Call) RunAndReturn

type MockClientInterface_Expecter

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

func (*MockClientInterface_Expecter) CreateBackup

func (_e *MockClientInterface_Expecter) CreateBackup(ctx interface{}, namespace interface{}, backupName interface{}, clusterName interface{}, opts interface{}) *MockClientInterface_CreateBackup_Call

CreateBackup is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • backupName string
  • clusterName string
  • opts CreateBackupOptions

func (*MockClientInterface_Expecter) CreateCluster

func (_e *MockClientInterface_Expecter) CreateCluster(ctx interface{}, namespace interface{}, clusterName interface{}, volumeSize interface{}, servingCertificateSecretName interface{}, clientCASecretName interface{}, replicationUserCertName interface{}, opts interface{}) *MockClientInterface_CreateCluster_Call

CreateCluster is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • clusterName string
  • volumeSize resource.Quantity
  • servingCertificateSecretName string
  • clientCASecretName string
  • replicationUserCertName string
  • opts CreateClusterOptions

func (*MockClientInterface_Expecter) DeleteBackup

func (_e *MockClientInterface_Expecter) DeleteBackup(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_DeleteBackup_Call

DeleteBackup is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) DeleteCluster

func (_e *MockClientInterface_Expecter) DeleteCluster(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_DeleteCluster_Call

DeleteCluster is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) GetCluster

func (_e *MockClientInterface_Expecter) GetCluster(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_GetCluster_Call

GetCluster is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) SetCommonLabels added in v0.0.9

func (_e *MockClientInterface_Expecter) SetCommonLabels(labels interface{}) *MockClientInterface_SetCommonLabels_Call

SetCommonLabels is a helper method to define mock.On call

  • labels map[string]string

func (*MockClientInterface_Expecter) WaitForClusterDeleted added in v0.0.13

func (_e *MockClientInterface_Expecter) WaitForClusterDeleted(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForClusterDeleted_Call

WaitForClusterDeleted is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForClusterDeletedOpts

func (*MockClientInterface_Expecter) WaitForReadyBackup

func (_e *MockClientInterface_Expecter) WaitForReadyBackup(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForReadyBackup_Call

WaitForReadyBackup is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForReadyBackupOpts

func (*MockClientInterface_Expecter) WaitForReadyCluster

func (_e *MockClientInterface_Expecter) WaitForReadyCluster(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForReadyCluster_Call

WaitForReadyCluster is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForReadyClusterOpts

type MockClientInterface_GetCluster_Call

type MockClientInterface_GetCluster_Call struct {
	*mock.Call
}

MockClientInterface_GetCluster_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCluster'

func (*MockClientInterface_GetCluster_Call) Return

func (*MockClientInterface_GetCluster_Call) Run

func (*MockClientInterface_GetCluster_Call) RunAndReturn

type MockClientInterface_SetCommonLabels_Call added in v0.0.9

type MockClientInterface_SetCommonLabels_Call struct {
	*mock.Call
}

MockClientInterface_SetCommonLabels_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCommonLabels'

func (*MockClientInterface_SetCommonLabels_Call) Return added in v0.0.9

func (*MockClientInterface_SetCommonLabels_Call) Run added in v0.0.9

func (*MockClientInterface_SetCommonLabels_Call) RunAndReturn added in v0.0.9

type MockClientInterface_WaitForClusterDeleted_Call added in v0.0.13

type MockClientInterface_WaitForClusterDeleted_Call struct {
	*mock.Call
}

MockClientInterface_WaitForClusterDeleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForClusterDeleted'

func (*MockClientInterface_WaitForClusterDeleted_Call) Return added in v0.0.13

func (*MockClientInterface_WaitForClusterDeleted_Call) Run added in v0.0.13

func (*MockClientInterface_WaitForClusterDeleted_Call) RunAndReturn added in v0.0.13

type MockClientInterface_WaitForReadyBackup_Call

type MockClientInterface_WaitForReadyBackup_Call struct {
	*mock.Call
}

MockClientInterface_WaitForReadyBackup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForReadyBackup'

func (*MockClientInterface_WaitForReadyBackup_Call) Return

func (*MockClientInterface_WaitForReadyBackup_Call) Run

func (*MockClientInterface_WaitForReadyBackup_Call) RunAndReturn

type MockClientInterface_WaitForReadyCluster_Call

type MockClientInterface_WaitForReadyCluster_Call struct {
	*mock.Call
}

MockClientInterface_WaitForReadyCluster_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForReadyCluster'

func (*MockClientInterface_WaitForReadyCluster_Call) Return

func (*MockClientInterface_WaitForReadyCluster_Call) Run

type VolumeSnapshotRecovery added in v0.0.13

type VolumeSnapshotRecovery struct {
	// DataSnapshotName is the name of the VolumeSnapshot holding PGDATA.
	DataSnapshotName string
	// WALSnapshotName is the name of the VolumeSnapshot holding the PG_WAL volume, if the source
	// cluster stores WAL on a separate volume. Optional.
	WALSnapshotName string
	// WALSource describes the external cluster from which write-ahead logs are fetched during
	// recovery. Its Name is used both as the bootstrap recovery source and, by CNPG convention,
	// as the server name (folder) the source cluster's backups are stored under, so it must match
	// the source cluster's barman server name.
	WALSource apiv1.ExternalCluster
}

VolumeSnapshotRecovery configures recovery of a new cluster from volume snapshots, with write-ahead logs fetched from an external cluster's WAL archive. This is the recovery path used for source clusters that archive WAL with the barman-cloud plugin (the in-tree barman support, driven by BackupName, recovers from a Backup object instead).

type WaitForClusterDeletedOpts added in v0.0.13

type WaitForClusterDeletedOpts struct {
	helpers.MaxWaitTime
}

type WaitForReadyBackupOpts

type WaitForReadyBackupOpts struct {
	helpers.MaxWaitTime
}

type WaitForReadyClusterOpts

type WaitForReadyClusterOpts struct {
	helpers.MaxWaitTime
}

Directories

Path Synopsis
gen
clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
clientset/versioned/typed/api/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clientset/versioned/typed/api/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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