util

package
v0.9.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 45 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServiceName string
)

Functions

func AttachLocalBackend

func AttachLocalBackend(podSpec core.PodSpec, localSpec store.LocalSpec) core.PodSpec

func AttachPVC

func AttachPVC(podSpec core.PodSpec, volumes []core.Volume, volumeMounts []core.VolumeMount) core.PodSpec

func BackupBatchEqual

func BackupBatchEqual(old, new *v1beta1.BackupBatch) bool

BackupBatchEqual check whether two BackupBatches has same specification.

func BackupConfigurationEqual

func BackupConfigurationEqual(old, new *v1beta1_api.BackupConfiguration) bool

BackupConfigurationEqual check whether two BackupConfigurations has same specification.

func BackupModel

func BackupModel(kind string) string

func BackupOptionsForBackupTarget

func BackupOptionsForBackupTarget(backupTarget *api.BackupTarget, retentionPolicy api_v1alpha1.RetentionPolicy, extraOpt ExtraOptions) restic.BackupOptions

func BackupPending

func BackupPending(phase v1beta1_api.BackupSessionPhase) bool

func CreateBatchPVC

func CreateBatchPVC(kubeClient kubernetes.Interface, namespace string, pvcList []core.PersistentVolumeClaim) error

CreateBatchPVC creates a batch of PVCs whose definitions has been provided in pvcList argument

func DeleteAllConfigMapLocks

func DeleteAllConfigMapLocks(k8sClient kubernetes.Interface, namespace, name, kind string) error

func DeleteBackupConfigMapLock

func DeleteBackupConfigMapLock(k8sClient kubernetes.Interface, namespace string, r v1beta1_api.TargetRef) error

func DeleteConfigmapLock

func DeleteConfigmapLock(k8sClient kubernetes.Interface, namespace string, workload api.LocalTypedReference) error

func DeleteRestoreConfigMapLock

func DeleteRestoreConfigMapLock(k8sClient kubernetes.Interface, namespace string, r v1beta1_api.TargetRef) error

func EnsureDefaultFunctions

func EnsureDefaultFunctions(stashClient cs.Interface, registry, imageTag string) error

EnsureDefaultFunctions creates "update-status", "pvc-backup" and "pvc-restore" Functions if they are not already present

func EnsureDefaultTasks

func EnsureDefaultTasks(stashClient cs.Interface) error

EnsureDefaultTasks creates "pvc-backup" and "pvc-restore" Tasks if they are not already present

func EnsureVolumeDeleted

func EnsureVolumeDeleted(volumes []core.Volume, name string) []core.Volume

func ExecuteHook

func ExecuteHook(config *rest.Config, hook interface{}, hookType, podName, namespace string) error

func FindBackupBatch

func FindBackupBatch(lister v1beta1_listers.BackupBatchLister, w *wapi.Workload) (*v1beta1.BackupBatch, error)

FindBackupBatch check if there is any BackupBatch exist for a particular workload. If multiple BackupBatches are found for the workload, it returns error.

func FindBackupConfigForRepository

func FindBackupConfigForRepository(stashClient cs.Interface, repository v1alpha1.Repository) (*v1beta1_api.BackupConfiguration, error)

func FindBackupConfiguration

FindBackupConfiguration check if there is any BackupConfiguration exist for a particular workload. If multiple BackupConfigurations are found for the workload, it returns error.

func FindRestic

func FindRestic(lister stash_listers.ResticLister, obj metav1.ObjectMeta) (*api.Restic, error)

func FindRestoreSession

FindRestoreSession check if there is any pending RestoreSession exist for a particular workload. If multiple pending RestoreSessions are found for the workload, it returns error.

func FixBackendPrefix

func FixBackendPrefix(backend *store.Backend, autoPrefix string) *store.Backend

func GetAppliedBackupBatch

func GetAppliedBackupBatch(m map[string]string) (*v1beta1.BackupBatch, error)

GetAppliedBackupBatch check whether BackupBatch was applied as annotation and returns the object definition if exist.

func GetAppliedBackupConfiguration

func GetAppliedBackupConfiguration(m map[string]string) (*v1beta1_api.BackupConfiguration, error)

GetAppliedBackupConfiguration check whether BackupConfiguration was applied as annotation and returns the object definition if exist.

func GetAppliedRestic

func GetAppliedRestic(m map[string]string) (*api.Restic, error)

func GetAppliedRestoreSession

func GetAppliedRestoreSession(m map[string]string) (*v1beta1_api.RestoreSession, error)

GetAppliedRestoreSession check whether RestoreSession was applied as annotation and returns the object definition if exist.

func GetBackupConfigmapLockName

func GetBackupConfigmapLockName(r v1beta1_api.TargetRef) string

func GetBucketAndPrefix

func GetBucketAndPrefix(backend *store.Backend) (string, string, error)

TODO: move to store

func GetConfigmapLockName

func GetConfigmapLockName(workload api.LocalTypedReference) string

func GetHostName

func GetHostName(target interface{}) (string, error)

GetHostName returns hostname for a target

func GetRepoNameAndSnapshotID

func GetRepoNameAndSnapshotID(snapshotName string) (repoName, snapshotId string, err error)

func GetRestoreConfigmapLockName

func GetRestoreConfigmapLockName(r v1beta1_api.TargetRef) string

func GetRestoreHostName

func GetRestoreHostName(stashClient cs.Interface, restoreSessionName, namespace string) (string, error)

func GetString

func GetString(m map[string]string, key string) string

func GetWorkloadReference

func GetWorkloadReference(w *wapi.Workload) (*core.ObjectReference, error)

GetWorkloadReference return reference of the workload.

func HasOldReplicaAnnotation

func HasOldReplicaAnnotation(k8sClient *kubernetes.Clientset, namespace string, workload api.LocalTypedReference) bool

func HasStashContainer

func HasStashContainer(w *wapi.Workload) bool

func HasStashInitContainer

func HasStashInitContainer(containers []core.Container) bool

func HasStashSidecar

func HasStashSidecar(containers []core.Container) bool

func HookExecutorContainer

func HookExecutorContainer(name string, shiblings []core.Container, invokerType, invokerName, targetKind, targetName string) core.Container

func IONiceSettingsFromEnv

func IONiceSettingsFromEnv() (*v1.IONiceSettings, error)

func IsBackupTarget

func IsBackupTarget(target *v1beta1_api.BackupTarget, w *wapi.Workload) bool

func IsRestoreTarget

func IsRestoreTarget(target *v1beta1_api.RestoreTarget, w *wapi.Workload) bool

func MergeLocalVolume

func MergeLocalVolume(volumes []core.Volume, backend *store.Backend) []core.Volume

func NewBackupSidecarContainer

func NewBackupSidecarContainer(invoker apis.Invoker, targetInfo apis.TargetInfo, backend *store.Backend, image docker.Docker) core.Container

func NewCheckJob

func NewCheckJob(restic *api_v1alpha1.Restic, hostName, smartPrefix string, image docker.Docker) *batch.Job

func NewPVCRestorerJob

func NewPVCRestorerJob(rs *api_v1beta1.RestoreSession, repository *api_v1alpha1.Repository, image docker.Docker) (*core.PodTemplateSpec, error)

NewPVCRestorerJob return a job definition to restore pvc.

func NewRecoveryJob

func NewRecoveryJob(stashClient cs.Interface, recovery *api_v1alpha1.Recovery, image docker.Docker) (*batch.Job, error)

func NewRestoreInitContainer

func NewRestoreInitContainer(rs *v1beta1_api.RestoreSession, repository *v1alpha1_api.Repository, image docker.Docker) core.Container

func NewSidecarContainer

func NewSidecarContainer(r *api.Restic, workload api.LocalTypedReference, image docker.Docker) core.Container

func NewVolumeRestorerJob

func NewVolumeRestorerJob(rs *api_v1beta1.RestoreSession, image docker.Docker) (*core.PodTemplateSpec, error)

func NewVolumeSnapshotterJob

func NewVolumeSnapshotterJob(bs *api_v1beta1.BackupSession, backupTarget *api_v1beta1.BackupTarget, runtimeSettings v1.RuntimeSettings, image docker.Docker) (*core.PodTemplateSpec, error)

func NiceSettingsFromEnv

func NiceSettingsFromEnv() (*v1.NiceSettings, error)

func PVCListToVolumes

func PVCListToVolumes(pvcList []core.PersistentVolumeClaim, ordinal int32) []core.Volume

PVCListToVolumes return a list of volumes to mount in pod for a list of PVCs

func ParseInt32P

func ParseInt32P(v string) (*int32, error)

func PushgatewayURL

func PushgatewayURL() string

func RecoveryEqual

func RecoveryEqual(old, new *api.Recovery) bool

func ResticEqual

func ResticEqual(old, new *api.Restic) bool

func RestoreOptionForRestoreSession

func RestoreOptionForRestoreSession(restoreSession api.RestoreSession, extraOpt ExtraOptions) restic.RestoreOptions

func RestoreOptionsForHost

func RestoreOptionsForHost(hostname string, rules []api.Rule) restic.RestoreOptions

return the matching rule if targetHosts is empty for a rule, it will match any hostname

func RestoreSessionEqual

func RestoreSessionEqual(old, new *v1beta1_api.RestoreSession) bool

RestoreSessionEqual check whether two RestoreSessions has same specification.

func SetupOptionsForRepository

func SetupOptionsForRepository(repository api_v1alpha1.Repository, extraOpt ExtraOptions) (restic.SetupOptions, error)

func UpsertDefaultPodSecurityContext

func UpsertDefaultPodSecurityContext(currentSC *core.PodSecurityContext) *core.PodSecurityContext

func UpsertInterimVolume

func UpsertInterimVolume(kubeClient kubernetes.Interface, podSpec core.PodSpec, interimVolumeTemplate *core.PersistentVolumeClaim, namespace string, owner *metav1.OwnerReference) (core.PodSpec, error)

UpsertInterimVolume create a PVC according to InterimVolumeTemplate and attach it to the respective pod

func UpsertPodSecurityContext

func UpsertPodSecurityContext(currentSC, newSC *core.PodSecurityContext) *core.PodSecurityContext

UpsertPodSecurityContext update current SecurityContext with new SecurityContext. If a field is not present in the new SecurityContext, value of the current SecurityContext for this field will be used.

func UpsertScratchVolume

func UpsertScratchVolume(volumes []core.Volume) []core.Volume

func UpsertSecretVolume

func UpsertSecretVolume(volumes []core.Volume, secretName string) []core.Volume

func UpsertSecurityContext

func UpsertSecurityContext(currentSC, newSC *core.SecurityContext) *core.SecurityContext

UpsertSecurityContext update current SecurityContext with new SecurityContext. If a field is not present in the new SecurityContext, value of the current SecurityContext for this field will be used.

func UpsertTmpVolume

func UpsertTmpVolume(volumes []core.Volume, settings v1beta1_api.EmptyDirSettings) []core.Volume

func UpsertTmpVolumeMount

func UpsertTmpVolumeMount(volumeMounts []core.VolumeMount) []core.VolumeMount

func WaitUntilDaemonSetReady

func WaitUntilDaemonSetReady(kubeClient kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilDeploymentConfigReady

func WaitUntilDeploymentConfigReady(c oc_cs.Interface, meta metav1.ObjectMeta) error

func WaitUntilDeploymentReady

func WaitUntilDeploymentReady(c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilPVCReady

func WaitUntilPVCReady(c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilRCReady

func WaitUntilRCReady(c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilReplicaSetReady

func WaitUntilReplicaSetReady(c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilStatefulSetReady

func WaitUntilStatefulSetReady(kubeClient kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilVolumeSnapshotReady

func WaitUntilVolumeSnapshotReady(c snapshot_cs.Interface, meta metav1.ObjectMeta) error

func WorkloadExists

func WorkloadExists(k8sClient kubernetes.Interface, namespace string, workload api.LocalTypedReference) error

func WorkloadReplicas

func WorkloadReplicas(kubeClient *kubernetes.Clientset, namespace string, workloadKind string, workloadName string) (int32, error)

Types

type ExtraOptions

type ExtraOptions struct {
	Host        string
	SecretDir   string
	CacertFile  string
	ScratchDir  string
	EnableCache bool
}

options that don't come from repository, backup-config, backup-session, restore-session

type RepoLabelData

type RepoLabelData struct {
	WorkloadKind string
	WorkloadName string
	PodName      string
	NodeName     string
}

func ExtractDataFromRepositoryLabel

func ExtractDataFromRepositoryLabel(labels map[string]string) (data RepoLabelData, err error)

type WorkloadClients

type WorkloadClients struct {
	KubeClient       kubernetes.Interface
	OcClient         oc_cs.Interface
	StashClient      cs.Interface
	CRDClient        crd_cs.ApiextensionsV1beta1Interface
	AppCatalogClient appcatalog_cs.Interface
}

func (*WorkloadClients) IsTargetExist

func (wc *WorkloadClients) IsTargetExist(target api_v1beta1.TargetRef, namespace string) bool

Jump to

Keyboard shortcuts

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