function

package
v0.0.0-...-a46d4d8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package function contains all common functions used in the project

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLabelAnnotationValueIsValid

func CheckLabelAnnotationValueIsValid(labelsOrAnnotations map[string]string, key string) bool

CheckLabelAnnotationValueIsValid return true if key exists among labels/annotations and has a valid length, false otherwise

func CheckVeleroBackupAnnotations

func CheckVeleroBackupAnnotations(obj client.Object) bool

CheckVeleroBackupAnnotations return true if Velero Backup object has required Non Admin annotations, false otherwise

func CheckVeleroBackupMetadata

func CheckVeleroBackupMetadata(obj client.Object) bool

CheckVeleroBackupMetadata return true if Velero Backup object has required Non Admin labels and annotations, false otherwise

func CheckVeleroBackupStorageLocationAnnotations

func CheckVeleroBackupStorageLocationAnnotations(obj client.Object) bool

CheckVeleroBackupStorageLocationAnnotations return true if Velero BackupStorageLocation object has required Non Admin annotations, false otherwise

func CheckVeleroBackupStorageLocationMetadata

func CheckVeleroBackupStorageLocationMetadata(obj client.Object) bool

CheckVeleroBackupStorageLocationMetadata return true if Velero BackupStorageLocation object has required Non Admin labels and annotations, false otherwise

func CheckVeleroRestoreAnnotations

func CheckVeleroRestoreAnnotations(obj client.Object) bool

CheckVeleroRestoreAnnotations return true if Velero Restore object has required Non Admin annotations, false otherwise

func CheckVeleroRestoreMetadata

func CheckVeleroRestoreMetadata(obj client.Object) bool

CheckVeleroRestoreMetadata return true if Velero Restore object has required Non Admin labels and annotations, false otherwise

func ComputePrefixForObjectStorage

func ComputePrefixForObjectStorage(namespace, customPrefix string) string

ComputePrefixForObjectStorage returns the prefix to be used for the BackupStorageLocation. If a custom prefix is provided, it returns "<namespace>/<customPrefix>". Otherwise, it returns the namespace name.

func GenerateNacObjectUUID

func GenerateNacObjectUUID(namespace, nacName string) string

GenerateNacObjectUUID generates a unique name based on the provided namespace and object origin name. It includes a UUID suffix. If the name exceeds the maximum length, it truncates nacName first, then namespace.

func GetActiveVeleroBackupsByLabel

func GetActiveVeleroBackupsByLabel(ctx context.Context, clientInstance client.Client, namespace, labelKey, labelValue string) ([]velerov1.Backup, error)

GetActiveVeleroBackupsByLabel retrieves all VeleroBackup objects based on a specified label within a given namespace. It returns a slice of VeleroBackup objects or nil if none are found.

func GetActiveVeleroRestoresByLabel

func GetActiveVeleroRestoresByLabel(ctx context.Context, clientInstance client.Client, namespace, labelKey, labelValue string) ([]velerov1.Restore, error)

GetActiveVeleroRestoresByLabel retrieves all VeleroRestore objects based on a specified label within a given namespace. It returns a slice of VeleroRestore objects or nil if none are found.

func GetBackupQueueInfo

func GetBackupQueueInfo(ctx context.Context, clientInstance client.Client, namespace string, targetBackup *velerov1.Backup) (nacv1alpha1.QueueInfo, error)

GetBackupQueueInfo determines the queue position of the specified VeleroBackup. It calculates how many queued Backups exist in the namespace that were created before this one.

func GetBslSecretByLabel

func GetBslSecretByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*corev1.Secret, error)

GetBslSecretByLabel retrieves a Secret object based on a specified label within a given namespace. It returns the Secret only when exactly one object is found, throws an error if multiple secrets are found, or returns nil if no matches are found.

func GetLogger

func GetLogger(ctx context.Context, obj client.Object, key string) logr.Logger

GetLogger return a logger from input ctx, with additional key/value pairs being input key and input obj name and namespace

func GetNabslRequestByLabel

func GetNabslRequestByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*nacv1alpha1.NonAdminBackupStorageLocationRequest, error)

GetNabslRequestByLabel retrieves a NonAdminBackupStorageLocationRequest object based on a specified label within a given namespace. It returns the NonAdminBackupStorageLocationRequest only when exactly one object is found, throws an error if multiple NonAdminBackupStorageLocationRequests are found, or returns nil if no matches are found.

func GetNonAdminBackupAnnotations

func GetNonAdminBackupAnnotations(objectMeta metav1.ObjectMeta) map[string]string

GetNonAdminBackupAnnotations return the required Non Admin annotations

func GetNonAdminBackupStorageLocationAnnotations

func GetNonAdminBackupStorageLocationAnnotations(objectMeta metav1.ObjectMeta) map[string]string

GetNonAdminBackupStorageLocationAnnotations return the required Non Admin annotations

func GetNonAdminDownloadRequestAnnotations

func GetNonAdminDownloadRequestAnnotations(objectMeta *nacv1alpha1.NonAdminDownloadRequest) map[string]string

GetNonAdminDownloadRequestAnnotations return the required Non Admin annotations

func GetNonAdminLabels

func GetNonAdminLabels() map[string]string

GetNonAdminLabels return the required Non Admin labels

func GetNonAdminRestoreAnnotations

func GetNonAdminRestoreAnnotations(objectMeta metav1.ObjectMeta) map[string]string

GetNonAdminRestoreAnnotations return the required Non Admin restore annotations

func GetNonAdminRestoreLabels

func GetNonAdminRestoreLabels(uniqueIdentifier string) map[string]string

GetNonAdminRestoreLabels return the required Non Admin restore labels

func GetRestoreQueueInfo

func GetRestoreQueueInfo(ctx context.Context, clientInstance client.Client, namespace string, targetRestore *velerov1.Restore) (nacv1alpha1.QueueInfo, error)

GetRestoreQueueInfo determines the queue position of the specified VeleroRestore. It calculates how many queued Restores exist in the namespace that were created before this one.

func GetVeleroBackupByLabel

func GetVeleroBackupByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*velerov1.Backup, error)

GetVeleroBackupByLabel retrieves a VeleroBackup object based on a specified label within a given namespace. It returns the VeleroBackup only when exactly one object is found, throws an error if multiple backups are found, or returns nil if no matches are found.

func GetVeleroBackupStorageLocationByLabel

func GetVeleroBackupStorageLocationByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*velerov1.BackupStorageLocation, error)

GetVeleroBackupStorageLocationByLabel retrieves a VeleroBackupStorageLocation object based on a specified label within a given namespace. It returns the VeleroBackupStorageLocation only when exactly one object is found, throws an error if multiple VeleroBackupStorageLocation are found, or returns nil if no matches are found.

func GetVeleroDeleteBackupRequestByLabel

func GetVeleroDeleteBackupRequestByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*velerov1.DeleteBackupRequest, error)

GetVeleroDeleteBackupRequestByLabel retrieves a DeleteBackupRequest object based on a specified label within a given namespace. It returns the DeleteBackupRequest only when exactly one object is found, throws an error if multiple backups are found, or returns nil if no matches are found.

func GetVeleroRestoreByLabel

func GetVeleroRestoreByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelValue string) (*velerov1.Restore, error)

GetVeleroRestoreByLabel retrieves a VeleroRestore object based on a specified label within a given namespace. It returns the VeleroRestore only when exactly one object is found, throws an error if multiple restores are found, or returns nil if no matches are found.

func ListObjectsByLabel

func ListObjectsByLabel(ctx context.Context, clientInstance client.Client, namespace string, labelKey string, labelValue string, objectList client.ObjectList) error

ListObjectsByLabel retrieves a list of Kubernetes objects in a specified namespace that match a given label key-value pair.

func ValidateBackupSpec

func ValidateBackupSpec(ctx context.Context, clientInstance client.Client, oadpNamespace string, nonAdminBackup *nacv1alpha1.NonAdminBackup, enforcedBackupSpec *velerov1.BackupSpec) error

ValidateBackupSpec return nil, if NonAdminBackup is valid; error otherwise

func ValidateBslSpec

func ValidateBslSpec(ctx context.Context, clientInstance client.Client, nonAdminBsl *nacv1alpha1.NonAdminBackupStorageLocation, enforcedBSLSpec *oadpv1alpha1.EnforceBackupStorageLocationSpec, appliedBackupSyncPeriod time.Duration, defaultBackupSyncPeriod *time.Duration) error

ValidateBslSpec return nil, if NonAdminBackupStorageLocation is valid; error otherwise

func ValidateRestoreSpec

func ValidateRestoreSpec(ctx context.Context, clientInstance client.Client, nonAdminRestore *nacv1alpha1.NonAdminRestore, enforcedRestoreSpec *velerov1.RestoreSpec) error

ValidateRestoreSpec return nil, if NonAdminRestore is valid; error otherwise

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳