Documentation
¶
Index ¶
- Constants
- func AppendEnvIfPresent(envs []corev1.EnvVar, name string) []corev1.EnvVar
- func AppendOverwriteEnv(a, b []corev1.EnvVar) []corev1.EnvVar
- func CheckAllKeysExistInSecret(secret *corev1.Secret, keys ...string) (string, bool)
- func CombineStringMap(maps ...map[string]string) map[string]string
- func CopyStringMap(src map[string]string) map[string]string
- func FirstPDGroup(ctx context.Context, cli client.Client, ns, cluster string) (*v1alpha1.PDGroup, error)
- func FirstTikvGroup(ctx context.Context, cli client.Client, ns, cluster string) (*v1alpha1.TiKVGroup, error)
- func GenStorageArgsForFlag(provider v1alpha1.StorageProvider, flag string) ([]string, error)
- func GenerateStorageCertEnv(ctx context.Context, ns string, useKMS bool, ...) ([]corev1.EnvVar, string, error)
- func GenerateStorageVolumesAndMounts(ctx context.Context, ns string, provider brv1alpha1.StorageProvider) ([]corev1.Volume, []corev1.VolumeMount, error)
- func GenerateTidbPasswordEnv(ctx context.Context, ns, tcName, tidbSecretName string, useKMS bool, ...) ([]corev1.EnvVar, string, error)
- func GetBackupBucketName(backup *brv1alpha1.Backup) (bucket, reason string, err error)
- func GetBackupDataPath(provider brv1alpha1.StorageProvider) (backupPath, reason string, err error)
- func GetBackupPrefixName(backup *brv1alpha1.Backup) (prefix, reason string, err error)
- func GetOptions(provider brv1alpha1.StorageProvider) []string
- func GetStoragePath(privoder brv1alpha1.StorageProvider) (string, error)
- func GetStorageType(provider brv1alpha1.StorageProvider) brv1alpha1.BackupStorageType
- func ParseImage(image string) (name, tag string)
- func UpdateBRProgress(progresses []brv1alpha1.Progress, step *string, progress *int, ...) ([]brv1alpha1.Progress, bool)
- func ValidateBackup(backup *brv1alpha1.Backup, tikvVersion string, cluster *corev1alpha1.Cluster) error
- func ValidateRestore(restore *brv1alpha1.Restore, tikvVersion string) error
- type BatchDeleteObjectsResult
- type MockDriver
- func (d *MockDriver) As(i any) bool
- func (d *MockDriver) Delete(_ context.Context, key string) error
- func (d *MockDriver) ErrorCode(err error) gcerrors.ErrorCode
- func (d *MockDriver) ListPaged(ctx context.Context, opts *driver.ListOptions) (*driver.ListPage, error)
- func (d *MockDriver) SetDelete(fn func(key string) error)
- func (d *MockDriver) SetListPaged(objs []*driver.ListObject, rerr error)
- type ObjectError
- type PageIterator
- type StorageBackend
- func (b *StorageBackend) AsGCS() (*storage.Client, bool)
- func (b *StorageBackend) AsS3() (*s3.S3, bool)
- func (b *StorageBackend) BatchDeleteObjects(ctx context.Context, objs []*blob.ListObject, opt v1alpha1.BatchDeleteOption) *BatchDeleteObjectsResult
- func (b *StorageBackend) GetBucket() string
- func (b *StorageBackend) GetPrefix() string
- func (b *StorageBackend) ListPage(opts *blob.ListOptions) *PageIterator
- func (b *StorageBackend) StorageType() v1alpha1.BackupStorageType
- type StorageCredential
Constants ¶
const (
ReasonUnsupportedStorageType = "UnsupportedStorageType"
)
Variables ¶
This section is empty.
Functions ¶
func AppendEnvIfPresent ¶
AppendEnvIfPresent appends the given environment if present
func AppendOverwriteEnv ¶
AppendOverwriteEnv appends envs b into a and overwrites the envs whose names already exist in b. Note that this will not change relative order of envs.
func CheckAllKeysExistInSecret ¶
CheckAllKeysExistInSecret check if all keys are included in the specific secret return the not-exist keys join by ","
func CombineStringMap ¶
CombineStringMap merges maps into a new map. NOTE: if the same key exists in multiple source maps, the value of the first one will be kept. so we suggest to :
- pass the map generated by TiDB-Operator as the first argument.
- pass components' map (labels or annotations) before cluster's.
func CopyStringMap ¶
CopyStringMap copy annotations to a new string map
func FirstPDGroup ¶
func FirstTikvGroup ¶
func GenStorageArgsForFlag ¶
func GenStorageArgsForFlag(provider v1alpha1.StorageProvider, flag string) ([]string, error)
GenStorageArgsForFlag returns the arg for --flag option and the remote/local path for br, default flag is storage. TODO: add unit test
func GenerateStorageCertEnv ¶
func GenerateStorageCertEnv( ctx context.Context, ns string, useKMS bool, provider brv1alpha1.StorageProvider, cli client.Client, ) ([]corev1.EnvVar, string, error)
GenerateStorageCertEnv generate the env info in order to access backend backup storage nolint: gocyclo
func GenerateStorageVolumesAndMounts ¶
func GenerateStorageVolumesAndMounts( ctx context.Context, ns string, provider brv1alpha1.StorageProvider, ) ([]corev1.Volume, []corev1.VolumeMount, error)
func GenerateTidbPasswordEnv ¶
func GenerateTidbPasswordEnv( ctx context.Context, ns, tcName, tidbSecretName string, useKMS bool, cli client.Client, ) ([]corev1.EnvVar, string, error)
GenerateTidbPasswordEnv generate the password EnvVar
func GetBackupBucketName ¶
func GetBackupBucketName(backup *brv1alpha1.Backup) (bucket, reason string, err error)
GetBackupBucketName return the bucket name for remote storage
func GetBackupDataPath ¶
func GetBackupDataPath(provider brv1alpha1.StorageProvider) (backupPath, reason string, err error)
GetBackupDataPath return the full path of backup data
func GetBackupPrefixName ¶
func GetBackupPrefixName(backup *brv1alpha1.Backup) (prefix, reason string, err error)
GetBackupPrefixName return the prefix for remote storage
func GetOptions ¶
func GetOptions(provider brv1alpha1.StorageProvider) []string
GetOptions gets the rclone options
func GetStoragePath ¶
func GetStoragePath(privoder brv1alpha1.StorageProvider) (string, error)
GetStoragePath generate the path of a specific storage from Restore
func GetStorageType ¶
func GetStorageType(provider brv1alpha1.StorageProvider) brv1alpha1.BackupStorageType
GetStorageType return the backup storage type according to the specified StorageProvider
func ParseImage ¶
ParseImage returns the image name and the tag from the input image string
func UpdateBRProgress ¶
func UpdateBRProgress( progresses []brv1alpha1.Progress, step *string, progress *int, updateTime *metav1.Time, ) ([]brv1alpha1.Progress, bool)
UpdateBRProgress updates progress for backup/restore.
func ValidateBackup ¶
func ValidateBackup(backup *brv1alpha1.Backup, tikvVersion string, cluster *corev1alpha1.Cluster) error
ValidateBackup validates backup sepc nolint:gocyclo
func ValidateRestore ¶
func ValidateRestore(restore *brv1alpha1.Restore, tikvVersion string) error
ValidateRestore checks whether a restore spec is valid. nolint:gocyclo
Types ¶
type BatchDeleteObjectsResult ¶
type BatchDeleteObjectsResult struct {
Deleted []string
Errors []ObjectError
}
func BatchDeleteObjectsConcurrently ¶
func BatchDeleteObjectsConcurrently( ctx context.Context, bucket *blob.Bucket, objs []*blob.ListObject, concurrency int, ) *BatchDeleteObjectsResult
BatchDeleteObjectsConcurrently delete objects by multiple goroutine concurrently
func BatchDeleteObjectsOfS3 ¶
func BatchDeleteObjectsOfS3( ctx context.Context, s3cli s3iface.S3API, objs []*blob.ListObject, bucket, prefix string, concurrency int, ) *BatchDeleteObjectsResult
BatchDeleteObjectsOfS3 delete objects by batch delete api
type MockDriver ¶
type MockDriver struct {
driver.Bucket
Type v1alpha1.BackupStorageType
// contains filtered or unexported fields
}
MockDriver implement driver.Bucket
func (*MockDriver) As ¶
func (d *MockDriver) As(i any) bool
func (*MockDriver) ListPaged ¶
func (d *MockDriver) ListPaged(ctx context.Context, opts *driver.ListOptions) (*driver.ListPage, error)
func (*MockDriver) SetDelete ¶
func (d *MockDriver) SetDelete(fn func(key string) error)
func (*MockDriver) SetListPaged ¶
func (d *MockDriver) SetListPaged(objs []*driver.ListObject, rerr error)
type ObjectError ¶
type PageIterator ¶
type PageIterator struct {
// contains filtered or unexported fields
}
PageIterator iterates a page of objects via 'ListIterator'
func (*PageIterator) Next ¶
func (i *PageIterator) Next(ctx context.Context, pageSize int) ([]*blob.ListObject, error)
Next list a page of objects
If err == io.EOF, all objects of bucket have been read. If err == nil, a page of objects have been read. Otherwise, err occurs and return objects have been read.
TODO: use blob.ListPage after upgrade gocloud.dev denpendency to 0.21
type StorageBackend ¶
StorageBackend provide a generic storage backend
func NewStorageBackend ¶
func NewStorageBackend(provider v1alpha1.StorageProvider, cred *StorageCredential) (*StorageBackend, error)
NewStorageBackend creates new storage backend, now supports S3/GCS/Azblob/Local function called by both controller and backup/restore, since BR already has env config in BR pod, cred can be nil.
func (*StorageBackend) BatchDeleteObjects ¶
func (b *StorageBackend) BatchDeleteObjects( ctx context.Context, objs []*blob.ListObject, opt v1alpha1.BatchDeleteOption, ) *BatchDeleteObjectsResult
BatchDeleteObjects delete multi objects
Depending on storage type, it use function 'BatchDeleteObjectsOfS3' or 'BatchDeleteObjectsConcurrently'
func (*StorageBackend) GetBucket ¶
func (b *StorageBackend) GetBucket() string
GetBucket return bucket name
If provider is S3/GCS/Azblob, return bucket. Otherwise return empty string
func (*StorageBackend) GetPrefix ¶
func (b *StorageBackend) GetPrefix() string
GetPrefix return prefix
func (*StorageBackend) ListPage ¶
func (b *StorageBackend) ListPage(opts *blob.ListOptions) *PageIterator
func (*StorageBackend) StorageType ¶
func (b *StorageBackend) StorageType() v1alpha1.BackupStorageType
type StorageCredential ¶
type StorageCredential struct {
// contains filtered or unexported fields
}
func GetStorageCredential ¶
func GetStorageCredential( ctx context.Context, ns string, provider v1alpha1.StorageProvider, secretLister corelisterv1.SecretLister, ) *StorageCredential