function

package
v0.0.0-...-9fdcb88 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 15 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 CheckVeleroBackupMetadata

func CheckVeleroBackupMetadata(obj client.Object) bool

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

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 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 GetNonAdminBackupAnnotations

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

GetNonAdminBackupAnnotations return the required Non Admin annotations

func GetNonAdminLabels

func GetNonAdminLabels() map[string]string

GetNonAdminLabels return the required Non Admin labels

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 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 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(nonAdminBackup *nacv1alpha1.NonAdminBackup, enforcedBackupSpec *velerov1.BackupSpec) error

ValidateBackupSpec return nil, if NonAdminBackup 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