utils

package
v0.8.0-beta.35 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: AGPL-3.0 Imports: 34 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTolerations

func AddTolerations(podSpec *corev1.PodSpec) (err error)

func BuildEnvByCredential

func BuildEnvByCredential(pod *corev1.Pod, credential *dpv1alpha1.ConnectionCredential) []corev1.EnvVar

func CovertEnvToMap

func CovertEnvToMap(env []corev1.EnvVar) map[string]string

CovertEnvToMap coverts env array to map.

func EventsToString added in v0.8.0

func EventsToString(events *corev1.EventList) string

func GetActionSetByName

func GetActionSetByName(reqCtx intctrlutil.RequestCtx,
	cli client.Client, name string) (*dpv1alpha1.ActionSet, error)

GetActionSetByName gets the ActionSet by name.

func GetAssociatedPodsOfJob added in v0.8.0

func GetAssociatedPodsOfJob(ctx context.Context, cli client.Client, namespace, jobName string) (*corev1.PodList, error)

func GetBackupMethodByName added in v0.7.1

func GetBackupMethodByName(name string, backupPolicy *dpv1alpha1.BackupPolicy) *dpv1alpha1.BackupMethod

func GetBackupMethodsFromBackupPolicy

func GetBackupMethodsFromBackupPolicy(backupPolicyList *dpv1alpha1.BackupPolicyList, backupPolicyName string) (string, map[string]struct{})

GetBackupMethodsFromBackupPolicy get backup methods from backup policy if backup policy is specified, search the backup policy with the name if backup policy is not specified, search the default backup policy if method's snapshotVolumes is true, use the method as the default backup method

func GetBackupPolicyByName added in v0.7.1

func GetBackupPolicyByName(
	reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	name string) (*dpv1alpha1.BackupPolicy, error)

func GetBackupType

func GetBackupType(actionSet *dpv1alpha1.ActionSet, useSnapshot *bool) dpv1alpha1.BackupType

func GetBackupVolumeSnapshotName

func GetBackupVolumeSnapshotName(backupName, volumeSource string) string

func GetFirstIndexRunningPod added in v0.7.2

func GetFirstIndexRunningPod(podList *corev1.PodList) *corev1.Pod

GetFirstIndexRunningPod gets the first running pod with index.

func GetKubeVersion added in v0.7.2

func GetKubeVersion() (int, int, error)

GetKubeVersion get the version of Kubernetes and return the version major and minor

func GetPodListByLabelSelector

func GetPodListByLabelSelector(reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	labelSelector metav1.LabelSelector) (*corev1.PodList, error)

func InjectDatasafed

func InjectDatasafed(podSpec *corev1.PodSpec, repo *dpv1alpha1.BackupRepo, repoVolumeMountPath string, backupPath string)

func InjectDatasafedWithConfig

func InjectDatasafedWithConfig(podSpec *corev1.PodSpec, configSecretName string, backupPath string)

func InjectDatasafedWithPVC

func InjectDatasafedWithPVC(podSpec *corev1.PodSpec, pvcName string, mountPath string, backupPath string)

func IsJobFinished

func IsJobFinished(job *batchv1.Job) (bool, batchv1.JobConditionType, string)

IsJobFinished if the job is completed or failed, return true. if the job is failed, return the failed message.

func MergeEnv

func MergeEnv(originalEnv, targetEnv []corev1.EnvVar) []corev1.EnvVar

MergeEnv merges the targetEnv to original env. if original env exist the same name var, it will be replaced.

func PrependSpaces added in v0.8.0

func PrependSpaces(content string, spaces int) string

PrependSpaces prepends spaces to each line of the content.

func RemoveDataProtectionFinalizer

func RemoveDataProtectionFinalizer(ctx context.Context, cli client.Client, obj client.Object) error

func SetControllerReference

func SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Scheme) error

func VolumeSnapshotEnabled

func VolumeSnapshotEnabled(ctx context.Context, cli client.Client, pod *corev1.Pod, volumes []string) (bool, error)

VolumeSnapshotEnabled checks if the volumes support snapshot.

Types

type PeriodicalEnqueueSource

type PeriodicalEnqueueSource struct {
	client.Client
	// contains filtered or unexported fields
}

PeriodicalEnqueueSource is an implementation of interface sigs.k8s.io/controller-runtime/pkg/source/Source It reads the specific resources from cache and enqueue them into the queue to trigger the reconcile procedure periodically.

func NewPeriodicalEnqueueSource

func NewPeriodicalEnqueueSource(
	client client.Client,
	objList client.ObjectList,
	period time.Duration,
	option PeriodicalEnqueueSourceOption) *PeriodicalEnqueueSource

func (*PeriodicalEnqueueSource) Start

func (*PeriodicalEnqueueSource) String

func (p *PeriodicalEnqueueSource) String() string

type PeriodicalEnqueueSourceOption

type PeriodicalEnqueueSourceOption struct {
	OrderFunc func(objList client.ObjectList) client.ObjectList
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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