util

package
v1.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAnnotations

func AddAnnotations(o *metav1.ObjectMeta, vals map[string]string)

AddAnnotations adds the supplied key-values to the annotations on the object

func Contains added in v1.2.0

func Contains(slice []string, key string) bool

func GetAnnotationFromSnapshot

func GetAnnotationFromSnapshot(itemSnapshot interface{}) (string, error)

func GetKubeClient

func GetKubeClient(config *rest.Config, logger logrus.FieldLogger) (*kubernetes.Clientset, error)

func GetPVForPVC added in v1.2.0

func GetPodVolumeNameForPVC added in v1.2.0

func GetPodVolumeNameForPVC(pod corev1.Pod, pvcName string) (string, error)

func GetPodsUsingPVC added in v1.2.0

func GetPodsUsingPVC(pvcNamespace, pvcName string, podsGetter corev1client.PodsGetter) ([]corev1.Pod, error)

func GetResources added in v1.2.0

func GetResources(blockListConfigMap map[string]string) []string

func GetSnapshotFromPVCAnnotation

func GetSnapshotFromPVCAnnotation(snapshotAnnotation string, itemSnapshot interface{}) error

func IsMigratedCSIVolume added in v1.4.0

func IsMigratedCSIVolume(pv *corev1.PersistentVolume) bool

func IsObjectBlocked added in v1.2.0

func IsObjectBlocked(item runtime.Unstructured) (bool, string, error)

func IsPVCBackedUpByFsBackup added in v1.4.3

func IsPVCBackedUpByFsBackup(pvcNamespace, pvcName string, podClient corev1client.PodsGetter, defaultVolumesToFsBackup bool) (bool, error)

func IsResourceBlocked added in v1.2.0

func IsResourceBlocked(resourceName string, resourcesToBlock map[string]string) bool

func IsResourceBlockedOnRestore added in v1.2.0

func IsResourceBlockedOnRestore(resourceName string) bool

func RemoveAnnotations added in v1.4.2

func RemoveAnnotations(o *metav1.ObjectMeta, keys []string)

RemoveAnnotations removes the supplied keys from the annotations on the object

func RetrieveStorageClassMapping

func RetrieveStorageClassMapping(config *rest.Config, veleroNs string, logger logrus.FieldLogger) (map[string]string, error)

func SelfLinkToCRDName

func SelfLinkToCRDName(selfLink string) string

* Converts a K8S Self Link into the CRD name. Supports namespaced and cluster level CRs * K8S Cluster Resource Self Link format: /api/<version>/<resource plural name>/<item name>, * e.g. /api/v1/persistentvolumes/pvc-3240e5ed-9a97-446c-a6ab-b2442d852d04 * K8S Namespace resource Self Link format: /api/<version>/namespaces/<namespace>/<resource plural name>/<item name>, * e.g. /api/v1/namespaces/kibishii/persistentvolumeclaims/etcd0-pv-claim * K8S Resource Name = <resource plural name>, e.g. persistentvolumes * Custom Resource Cluster Self Link format: /apis/<CR group>/<version>/<CR plural name>/<item name>, * e.g. /api/cnsdp.vmware.com/v1/backuprepositories/br-1 * Custom Resource Namespace Self Link format: /apis/<CR group>/<version>/namespaces/<namespace>/<CR plural name>/<item name>, * e.g. /apis/velero.io/v1/namespaces/velero/backups/kibishii-1 * Custom Resource Name = <CR plural name>.<CR group>, e.g. backups.velero.io

func SkipPVCCreation added in v1.2.0

func SkipPVCCreation(ctx context.Context, config *rest.Config, pvc *corev1.PersistentVolumeClaim, targetNamespace string, logger logrus.FieldLogger) (bool, error)

SkipPVCCreation checks whether to skip creation of the PVC. Returns true to indicate skipping PVC creation and false otherwise. If an error occurrs, it returns true and the error. If PVC already exists, it returns true and nil. If PVC is not found, it returns false and nil to indicate PVC should be created.

func UnstructuredToCRDName added in v1.1.1

func UnstructuredToCRDName(item runtime.Unstructured) (string, error)

* Extracts the CRD name from a K8S Unstructured into the CRD name. Supports namespaced and cluster level CRs * K8S Cluster Resource Self Link format: /api/<version>/<resource plural name>/<item name>, * e.g. /api/v1/persistentvolumes/pvc-3240e5ed-9a97-446c-a6ab-b2442d852d04 * K8S Resource Name = <resource plural name>, e.g. persistentvolumes * Custom Resource Cluster Self Link format: /apis/<CR group>/<version>/<CR plural name>/<item name>, * e.g. /api/cnsdp.vmware.com/v1/backuprepositories/br-1 * Custom Resource Name = <CR plural name>.<CR group>, e.g. backuprepositories.cnsdp.vmware.com * TODO - replace with a better system that does need singular to plural translation

func UpdateSnapshotWithNewNamespace

func UpdateSnapshotWithNewNamespace(itemSnapshot *backupdriverv1.Snapshot, namespace string) (backupdriverv1.Snapshot, error)

func UpdateSnapshotWithNewStorageClass

func UpdateSnapshotWithNewStorageClass(config *rest.Config, itemSnapshot *backupdriverv1.Snapshot, storageClassMapping map[string]string, logger logrus.FieldLogger) (backupdriverv1.Snapshot, error)

func ValidateRestoreStorageClass added in v1.5.3

func ValidateRestoreStorageClass(config *rest.Config, itemSnapshot *backupdriverv1.Snapshot, logger logrus.FieldLogger) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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