utils

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// LocalProviderDefaultMountPath is the default path where the buckets directory is mounted.
	LocalProviderDefaultMountPath = "/etc/gardener/local-backupbuckets"
	// EtcdBackupSecretHostPath is the hostPath field in the etcd-backup secret.
	EtcdBackupSecretHostPath = "hostPath"
)
View Source
const (
	// S3 is a constant for the AWS and S3 compliant storage provider.
	S3 = "S3"
	// ABS is a constant for the Azure storage provider.
	ABS = "ABS"
	// GCS is a constant for the Google storage provider.
	GCS = "GCS"
	// OSS is a constant for the Alicloud storage provider.
	OSS = "OSS"
	// Swift is a constant for the OpenStack storage provider.
	Swift = "Swift"
	// Local is a constant for the Local storage provider.
	Local = "Local"
	// ECS is a constant for the EMC storage provider.
	ECS = "ECS"
	// OCS is a constant for the OpenShift storage provider.
	OCS = "OCS"
)
View Source
const PurposeMemberLease = "etcd-member-lease"

PurposeMemberLease is a constant used as a purpose for etcd member lease objects.

Variables

This section is empty.

Functions

func ComputeScheduleInterval added in v0.22.0

func ComputeScheduleInterval(cronSchedule string) (time.Duration, error)

ComputeScheduleInterval computes the interval between two activations for the given cron schedule. Assumes that every cron activation is at equal intervals apart, based on cron schedules such as "once every X hours", "once every Y days", "at 1:00pm on every Tuesday", etc. TODO: write a new function to accurately compute the previous activation time from the cron schedule in order to compute when the previous activation of the cron schedule was supposed to have occurred, instead of relying on the assumption that all the cron activations are evenly spaced.

func GetBackupRestoreContainerEnvVars added in v0.22.0

func GetBackupRestoreContainerEnvVars(store *druidv1alpha1.StoreSpec) ([]corev1.EnvVar, error)

GetBackupRestoreContainerEnvVars returns backup-restore container environment variables for the given store

func GetEnvVarFromFieldPath added in v0.22.0

func GetEnvVarFromFieldPath(name, fieldPath string) corev1.EnvVar

GetEnvVarFromFieldPath returns environment variable object with provided name and value from field path

func GetEnvVarFromSecret added in v0.22.0

func GetEnvVarFromSecret(name, secretName, secretKey string, optional bool) corev1.EnvVar

GetEnvVarFromSecret returns environment variable object with provided name and optional value from secret

func GetEnvVarFromValue added in v0.22.0

func GetEnvVarFromValue(name, value string) corev1.EnvVar

GetEnvVarFromValue returns environment variable object with the provided name and value

func GetEtcdBackupRestoreImage added in v0.17.0

func GetEtcdBackupRestoreImage(iv imagevector.ImageVector, useEtcdWrapper bool) (*string, error)

GetEtcdBackupRestoreImage returns the image for backup-restore from the given image vector.

func GetEtcdImages added in v0.17.0

func GetEtcdImages(etcd *druidv1alpha1.Etcd, iv imagevector.ImageVector, useEtcdWrapper bool) (*string, *string, *string, error)

GetEtcdImages returns images for etcd and backup-restore by inspecting the etcd spec and the image vector and returns the image for the init container by inspecting the image vector. It will give preference to images that are set in the etcd spec and only if the image is not found in it should it be picked up from the image vector if it's set there. A return value of nil for either of the images indicates that the image is not set.

func GetHostMountPathFromSecretRef added in v0.13.0

func GetHostMountPathFromSecretRef(ctx context.Context, client client.Client, logger logr.Logger, store *druidv1alpha1.StoreSpec, namespace string) (string, error)

GetHostMountPathFromSecretRef returns the hostPath configured for the given store.

func GetInitContainerImage added in v0.20.3

func GetInitContainerImage(iv imagevector.ImageVector) (*string, error)

GetInitContainerImage returns the image for init container from the given image vector.

func GetMemberLeaseLabels added in v0.18.1

func GetMemberLeaseLabels(etcdName string) map[string]string

GetMemberLeaseLabels creates a map of default labels for member lease.

func GetProviderEnvVars added in v0.22.0

func GetProviderEnvVars(store *druidv1alpha1.StoreSpec) ([]corev1.EnvVar, error)

GetProviderEnvVars returns provider-specific environment variables for the given store

func GetStatefulSet added in v0.17.0

func GetStatefulSet(ctx context.Context, cl client.Client, etcd *druidv1alpha1.Etcd) (*appsv1.StatefulSet, error)

GetStatefulSet fetches StatefulSet created for the etcd.

func IsPeerURLTLSEnabled added in v0.18.1

func IsPeerURLTLSEnabled(ctx context.Context, cli client.Client, namespace, etcdName string, logger logr.Logger) (bool, error)

IsPeerURLTLSEnabled checks if the TLS has been enabled for all existing members of an etcd cluster identified by etcdName and in the provided namespace.

func IsStatefulSetReady added in v0.17.0

func IsStatefulSetReady(etcdReplicas int32, statefulSet *appsv1.StatefulSet) (bool, string)

IsStatefulSetReady checks whether the given StatefulSet is ready and up-to-date. A StatefulSet is considered healthy if its controller observed its current revision, it is not in an update (i.e. UpdateRevision is empty) and if its current replicas are equal to desired replicas specified in ETCD specs. It returns ready status (bool) and in case it is not ready then the second return value holds the reason.

func Key

func Key(namespaceOrName string, nameOpt ...string) client.ObjectKey

Key creates a new client.ObjectKey from the given parameters. There are only two ways to call this function:

  • If only namespaceOrName is set, then a client.ObjectKey with name set to namespaceOrName is returned.
  • If namespaceOrName and one nameOpt is given, then a client.ObjectKey with namespace set to namespaceOrName and name set to nameOpt[0] is returned.

For all other cases, this method panics.

func Max added in v0.6.0

func Max(x, y int) int

Max returns the larger of x or y.

func MergeStringMaps

func MergeStringMaps(oldMap map[string]string, newMaps ...map[string]string) map[string]string

MergeStringMaps merges the content of the newMaps with the oldMap. If a key already exists then it gets overwritten by the last value with the same key.

func StorageProviderFromInfraProvider

func StorageProviderFromInfraProvider(infra *druidv1alpha1.StorageProvider) (string, error)

StorageProviderFromInfraProvider converts infra to object store provider.

Types

This section is empty.

Jump to

Keyboard shortcuts

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