helper

package
v1.27.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 22 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = metav1.Now

Now determines the current metav1.Time.

Functions

func BackupBucketIsErroneous added in v1.18.0

func BackupBucketIsErroneous(bb *gardencorev1beta1.BackupBucket) (bool, string)

BackupBucketIsErroneous returns `true` if the given BackupBucket has a last error. It also returns the error description if available.

func ComputeOperationType

func ComputeOperationType(meta metav1.ObjectMeta, lastOperation *gardencorev1beta1.LastOperation) gardencorev1beta1.LastOperationType

ComputeOperationType checks the <lastOperation> and determines whether it is Create, Delete, Reconcile, Migrate or Restore operation

func ConditionsNeedUpdate

func ConditionsNeedUpdate(existingConditions, newConditions []gardencorev1beta1.Condition) bool

ConditionsNeedUpdate returns true if the <existingConditions> must be updated based on <newConditions>.

func DeleteLastErrorByTaskID added in v1.5.1

func DeleteLastErrorByTaskID(lastErrors []gardencorev1beta1.LastError, taskID string) []gardencorev1beta1.LastError

DeleteLastErrorByTaskID removes the 'last error' with the given task ID from the given 'last error' list.

func DetermineError

func DetermineError(err error, message string) error

DetermineError determines the Garden error code for the given error and creates a new error with the given message. TODO(timebertt): this is should be improved: clean up the usages to not pass the error twice (once as an error and once as a string) and properly wrap the given error instead of creating a new one from the given error message, so we can use errors.As up the call stack.

func DetermineErrorCodes added in v1.5.0

func DetermineErrorCodes(err error) []gardencorev1beta1.ErrorCode

DetermineErrorCodes determines error codes based on the given error.

func DetermineMachineImageForName

func DetermineMachineImageForName(cloudProfile *gardencorev1beta1.CloudProfile, name string) (bool, gardencorev1beta1.MachineImage, error)

DetermineMachineImageForName finds the cloud specific machine images in the <cloudProfile> for the given <name> and region. In case it does not find the machine image with the <name>, it returns false. Otherwise, true and the cloud-specific machine image will be returned.

func ExtractErrorCodes

func ExtractErrorCodes(err error) []gardencorev1beta1.ErrorCode

ExtractErrorCodes extracts all error codes from the given error by using utilerrors.Errors

func FilterDeprecatedVersion added in v1.24.3

func FilterDeprecatedVersion() func(expirableVersion gardencorev1beta1.ExpirableVersion, version *semver.Version) (bool, error)

FilterDeprecatedVersion returns a closure that evaluates whether a given expirable version is deprecated returns true if it is deprecated

func FilterExpiredVersion added in v1.4.0

func FilterExpiredVersion() func(expirableVersion gardencorev1beta1.ExpirableVersion, version *semver.Version) (bool, error)

FilterExpiredVersion returns a closure that evaluates whether a given expirable version is expired returns true if it is expired

func FindPrimaryDNSProvider added in v1.1.0

func FindPrimaryDNSProvider(providers []gardencorev1beta1.DNSProvider) *gardencorev1beta1.DNSProvider

FindPrimaryDNSProvider finds the primary provider among the given `providers`. It returns the first provider in case no primary provider is available or the first one if multiple candidates are found.

func FormatLastErrDescription

func FormatLastErrDescription(err error) string

FormatLastErrDescription formats the error message string for the last occurred error.

func GetCondition

func GetCondition(conditions []gardencorev1beta1.Condition, conditionType gardencorev1beta1.ConditionType) *gardencorev1beta1.Condition

GetCondition returns the condition with the given <conditionType> out of the list of <conditions>. In case the required type could not be found, it returns nil.

func GetDefaultMachineImageFromCloudProfile

func GetDefaultMachineImageFromCloudProfile(profile gardencorev1beta1.CloudProfile) *gardencorev1beta1.MachineImage

GetDefaultMachineImageFromCloudProfile gets the first MachineImage from the CloudProfile

func GetKubernetesVersionForMinorUpdate added in v1.4.0

func GetKubernetesVersionForMinorUpdate(cloudProfile *gardencorev1beta1.CloudProfile, currentVersion string) (bool, string, error)

GetKubernetesVersionForMinorUpdate finds a Kubernetes version in the <cloudProfile> that qualifies for a Kubernetes minor level update given a <currentVersion>. A qualifying version is a non-preview version having the minor version increased by exactly one version. In case the consecutive minor version has only expired versions, picks the latest expired version (will do another minor update during the next maintenance time) If a version can be found, returns true and the qualifying patch version of the next minor version. In case it does not find a version, it returns false.

func GetKubernetesVersionForPatchUpdate added in v1.4.0

func GetKubernetesVersionForPatchUpdate(cloudProfile *gardencorev1beta1.CloudProfile, currentVersion string) (bool, string, error)

GetKubernetesVersionForPatchUpdate finds the latest Kubernetes patch version for its minor version in the <cloudProfile> compared to the given <currentVersion>. Preview and expired versions do not qualify for the kubernetes patch update. In case it does not find a newer patch version, it returns false. Otherwise, true and the found version will be returned.

func GetLatestQualifyingShootMachineImage added in v1.4.0

func GetLatestQualifyingShootMachineImage(image gardencorev1beta1.MachineImage, predicates ...VersionPredicate) (bool, *gardencorev1beta1.ShootMachineImage, error)

GetLatestQualifyingShootMachineImage determines the latest qualifying version in a machine image and returns that as a ShootMachineImage. A version qualifies if its classification is not preview and the version is not expired. Older but non-deprecated version is preferred over newer but deprecated one.

func GetLatestQualifyingVersion added in v1.4.0

func GetLatestQualifyingVersion(versions []gardencorev1beta1.ExpirableVersion, predicate ...VersionPredicate) (qualifyingVersionFound bool, latest *gardencorev1beta1.ExpirableVersion, err error)

GetLatestQualifyingVersion returns the latest expirable version from a set of expirable versions A version qualifies if its classification is not preview and the optional predicate does not filter out the version. If the predicate returns true, the version is not considered for the latest qualifying version.

func GetOrInitCondition

func GetOrInitCondition(conditions []gardencorev1beta1.Condition, conditionType gardencorev1beta1.ConditionType) gardencorev1beta1.Condition

GetOrInitCondition tries to retrieve the condition with the given condition type from the given conditions. If the condition could not be found, it returns an initialized condition of the given type.

func GetPurpose added in v1.15.0

GetPurpose returns the purpose of the shoot or 'evaluation' if it's nil.

func GetResourceByName added in v1.5.0

GetResourceByName returns the first NamedResourceReference with the given name in the given slice, or nil if not found.

func HasErrorCode added in v1.22.0

func HasErrorCode(lastErrors []gardencorev1beta1.LastError, code gardencorev1beta1.ErrorCode) bool

HasErrorCode checks whether at least one LastError from the given slice of LastErrors <lastErrors> contains the given ErrorCode <code>.

func HasNonRetryableErrorCode added in v1.5.0

func HasNonRetryableErrorCode(lastErrors ...gardencorev1beta1.LastError) bool

HasNonRetryableErrorCode returns true if at least one of given list of last errors has at least one error code that indicates that an automatic retry would not help fixing the problem.

func HibernationIsEnabled

func HibernationIsEnabled(shoot *gardencorev1beta1.Shoot) bool

HibernationIsEnabled checks if the given shoot's desired state is hibernated.

func InitCondition

func InitCondition(conditionType gardencorev1beta1.ConditionType) gardencorev1beta1.Condition

InitCondition initializes a new Condition with an Unknown status.

func IsAPIServerExposureManaged added in v1.1.0

func IsAPIServerExposureManaged(obj metav1.Object) bool

IsAPIServerExposureManaged returns true, if the Object is managed by Gardener for API server exposure. This indicates to extensions that they should not mutate the object. Gardener marks the kube-apiserver Service and Deployment as managed by it when it uses SNI to expose them.

func IsControllerInstallationRequired added in v1.5.0

func IsControllerInstallationRequired(controllerInstallation gardencorev1beta1.ControllerInstallation) bool

IsControllerInstallationRequired returns true if a ControllerInstallation has been marked as "required".

func IsControllerInstallationSuccessful

func IsControllerInstallationSuccessful(controllerInstallation gardencorev1beta1.ControllerInstallation) bool

IsControllerInstallationSuccessful returns true if a ControllerInstallation has been marked as "successfully" installed.

func IsResourceSupported

func IsResourceSupported(resources []gardencorev1beta1.ControllerResource, resourceKind, resourceType string) bool

IsResourceSupported returns true if a given combination of kind/type is part of a controller resources list.

func KubernetesDashboardEnabled added in v1.15.0

func KubernetesDashboardEnabled(addons *gardencorev1beta1.Addons) bool

KubernetesDashboardEnabled returns true if the kubernetes-dashboard addon is enabled in the Shoot manifest.

func KubernetesVersionExistsInCloudProfile

func KubernetesVersionExistsInCloudProfile(cloudProfile *gardencorev1beta1.CloudProfile, currentVersion string) (bool, gardencorev1beta1.ExpirableVersion, error)

KubernetesVersionExistsInCloudProfile checks if the given Kubernetes version exists in the CloudProfile

func LastError

func LastError(description string, codes ...gardencorev1beta1.ErrorCode) *gardencorev1beta1.LastError

LastError creates a new LastError with the given description, optional codes and sets timestamp when the error is lastly observed.

func LastErrorWithTaskID

func LastErrorWithTaskID(description string, taskID string, codes ...gardencorev1beta1.ErrorCode) *gardencorev1beta1.LastError

LastErrorWithTaskID creates a new LastError with the given description, the ID of the task when the error occurred, optional codes and sets timestamp when the error is lastly observed.

func MergeConditions

func MergeConditions(oldConditions []gardencorev1beta1.Condition, newConditions ...gardencorev1beta1.Condition) []gardencorev1beta1.Condition

MergeConditions merges the given <oldConditions> with the <newConditions>. Existing conditions are superseded by the <newConditions> (depending on the condition type).

func NewErrorWithCodes added in v1.4.0

func NewErrorWithCodes(message string, codes ...gardencorev1beta1.ErrorCode) error

NewErrorWithCodes creates a new error that additionally exposes the given codes via the Coder interface.

func NginxIngressEnabled added in v1.15.0

func NginxIngressEnabled(addons *gardencorev1beta1.Addons) bool

NginxIngressEnabled returns true if the nginx-ingress addon is enabled in the Shoot manifest.

func SeedBackupSecretRefEqual added in v1.19.0

func SeedBackupSecretRefEqual(oldBackup, newBackup *gardencorev1beta1.SeedBackup) bool

SeedBackupSecretRefEqual returns true when the secret reference of the backup configuration is the same.

func SeedSettingVerticalPodAutoscalerEnabled added in v1.18.0

func SeedSettingVerticalPodAutoscalerEnabled(settings *gardencorev1beta1.SeedSettings) bool

SeedSettingVerticalPodAutoscalerEnabled returns true if the 'verticalPodAutoscaler' setting is enabled.

func SetMachineImageVersionsToMachineImage

func SetMachineImageVersionsToMachineImage(machineImages []gardencorev1beta1.MachineImage, imageName string, imageVersions []gardencorev1beta1.MachineImageVersion) ([]gardencorev1beta1.MachineImage, error)

SetMachineImageVersionsToMachineImage sets imageVersions to the matching imageName in the machineImages.

func ShootAuditPolicyConfigMapRefEqual added in v1.19.0

func ShootAuditPolicyConfigMapRefEqual(oldAPIServerConfig, newAPIServerConfig *gardencorev1beta1.KubeAPIServerConfig) bool

ShootAuditPolicyConfigMapRefEqual returns true if the name of the ConfigMap reference for the audit policy configuration is the same.

func ShootDNSProviderSecretNamesEqual added in v1.19.0

func ShootDNSProviderSecretNamesEqual(oldDNS, newDNS *gardencorev1beta1.DNS) bool

ShootDNSProviderSecretNamesEqual returns true when all the secretNames in the `.spec.dns.providers[]` list are the same.

func ShootIgnoresAlerts

func ShootIgnoresAlerts(shoot *gardencorev1beta1.Shoot) bool

ShootIgnoresAlerts checks if the alerts for the annotated shoot cluster should be ignored.

func ShootMachineImageVersionExists

func ShootMachineImageVersionExists(constraint gardencorev1beta1.MachineImage, image gardencorev1beta1.ShootMachineImage) (bool, int)

ShootMachineImageVersionExists checks if the shoot machine image (name, version) exists in the machine image constraint and returns true if yes and the index in the versions slice

func ShootSecretResourceReferencesEqual added in v1.19.0

func ShootSecretResourceReferencesEqual(oldResources, newResources []gardencorev1beta1.NamedResourceReference) bool

ShootSecretResourceReferencesEqual returns true when at least one of the Secret resource references inside a Shoot has been changed.

func ShootUsesUnmanagedDNS added in v0.34.0

func ShootUsesUnmanagedDNS(shoot *gardencorev1beta1.Shoot) bool

ShootUsesUnmanagedDNS returns true if the shoot's DNS section is marked as 'unmanaged'.

func ShootWantsAlertManager added in v1.15.0

func ShootWantsAlertManager(shoot *gardencorev1beta1.Shoot) bool

ShootWantsAlertManager checks if the given shoot specification requires an alert manager.

func ShootWantsAnonymousAuthentication added in v1.24.0

func ShootWantsAnonymousAuthentication(kubeAPIServerConfig *gardencorev1beta1.KubeAPIServerConfig) bool

ShootWantsAnonymousAuthentication returns true if anonymous authentication is set explicitly to 'true' and false otherwise.

func ShootWantsBasicAuthentication

func ShootWantsBasicAuthentication(shoot *gardencorev1beta1.Shoot) bool

ShootWantsBasicAuthentication returns true if basic authentication is not configured or if it is set explicitly to 'true'.

func ShootWantsClusterAutoscaler

func ShootWantsClusterAutoscaler(shoot *gardencorev1beta1.Shoot) (bool, error)

ShootWantsClusterAutoscaler checks if the given Shoot needs a cluster autoscaler. This is determined by checking whether one of the Shoot workers has a different Maximum than Minimum.

func ShootWantsVerticalPodAutoscaler added in v1.7.0

func ShootWantsVerticalPodAutoscaler(shoot *gardencorev1beta1.Shoot) bool

ShootWantsVerticalPodAutoscaler checks if the given Shoot needs a VPA.

func SystemComponentsAllowed added in v1.7.0

func SystemComponentsAllowed(worker *gardencorev1beta1.Worker) bool

SystemComponentsAllowed checks if the given worker allows system components to be scheduled onto it

func TaintsAreTolerated added in v1.6.0

func TaintsAreTolerated(taints []gardencorev1beta1.SeedTaint, tolerations []gardencorev1beta1.Toleration) bool

TaintsAreTolerated returns true when all the given taints are tolerated by the given tolerations.

func TaintsHave

func TaintsHave(taints []gardencorev1beta1.SeedTaint, key string) bool

TaintsHave returns true if the given key is part of the taints list.

func UpdateMachineImages

func UpdateMachineImages(workers []gardencorev1beta1.Worker, machineImages []*gardencorev1beta1.ShootMachineImage)

UpdateMachineImages updates the machine images in place.

func UpdatedCondition

func UpdatedCondition(condition gardencorev1beta1.Condition, status gardencorev1beta1.ConditionStatus, reason, message string, codes ...gardencorev1beta1.ErrorCode) gardencorev1beta1.Condition

UpdatedCondition updates the properties of one specific condition.

func UpdatedConditionUnknownError

func UpdatedConditionUnknownError(condition gardencorev1beta1.Condition, err error, codes ...gardencorev1beta1.ErrorCode) gardencorev1beta1.Condition

UpdatedConditionUnknownError updates the condition to 'Unknown' status and the message of the given error.

func UpdatedConditionUnknownErrorMessage

func UpdatedConditionUnknownErrorMessage(condition gardencorev1beta1.Condition, message string, codes ...gardencorev1beta1.ErrorCode) gardencorev1beta1.Condition

UpdatedConditionUnknownErrorMessage updates the condition with 'Unknown' status and the given message.

func UpsertLastError added in v1.5.1

func UpsertLastError(lastErrors []gardencorev1beta1.LastError, lastError gardencorev1beta1.LastError) []gardencorev1beta1.LastError

UpsertLastError adds a 'last error' to the given list of existing 'last errors' if it does not exist yet. Otherwise, it updates it.

func WrapWithLastError added in v0.34.0

func WrapWithLastError(err error, lastError *gardencorev1beta1.LastError) error

WrapWithLastError is wrapper function for gardencorev1beta1.LastError

Types

type Coder

type Coder interface {
	error
	Codes() []gardencorev1beta1.ErrorCode
}

Coder is an error that may produce a ErrorCodes visible to the outside.

type ConditionBuilder added in v0.34.0

type ConditionBuilder interface {
	WithOldCondition(old gardencorev1beta1.Condition) ConditionBuilder
	WithStatus(status gardencorev1beta1.ConditionStatus) ConditionBuilder
	WithReason(reason string) ConditionBuilder
	WithMessage(message string) ConditionBuilder
	WithCodes(codes ...gardencorev1beta1.ErrorCode) ConditionBuilder
	WithNowFunc(now func() metav1.Time) ConditionBuilder
	Build() (new gardencorev1beta1.Condition, updated bool)
}

ConditionBuilder build a Condition.

func NewConditionBuilder added in v0.34.0

func NewConditionBuilder(conditionType gardencorev1beta1.ConditionType) (ConditionBuilder, error)

NewConditionBuilder returns a ConditionBuilder for a specific condition.

type ErrorWithCodes added in v1.5.1

type ErrorWithCodes struct {
	// contains filtered or unexported fields
}

ErrorWithCodes contains error codes and an error message.

func (*ErrorWithCodes) Codes added in v1.5.1

Codes returns all error codes.

func (*ErrorWithCodes) Error added in v1.5.1

func (e *ErrorWithCodes) Error() string

Error returns the error message.

func (*ErrorWithCodes) Retriable added in v1.25.0

func (e *ErrorWithCodes) Retriable()

Retriable marks ErrorWithCodes as retriable.

type ShootItems added in v1.7.0

type ShootItems gardencorev1beta1.ShootList

ShootItems provides helper functions with ShootLists

func (*ShootItems) Union added in v1.7.0

func (s *ShootItems) Union(shootItems *ShootItems) []gardencorev1beta1.Shoot

Union returns a set of Shoots that presents either in s or shootList

type ShootedSeed

type ShootedSeed struct {
	DisableDNS                      *bool
	DisableCapacityReservation      *bool
	Protected                       *bool
	Visible                         *bool
	LoadBalancerServicesAnnotations map[string]string
	MinimumVolumeSize               *string
	APIServer                       *ShootedSeedAPIServer
	BlockCIDRs                      []string
	ShootDefaults                   *gardencorev1beta1.ShootNetworks
	Backup                          *gardencorev1beta1.SeedBackup
	SeedProviderConfig              *runtime.RawExtension
	IngressController               *gardencorev1beta1.IngressController
	NoGardenlet                     bool
	UseServiceAccountBootstrapping  bool
	WithSecretRef                   bool
	FeatureGates                    map[string]bool
	Resources                       *ShootedSeedResources
}

func ReadShootedSeed

func ReadShootedSeed(shoot *gardencorev1beta1.Shoot) (*ShootedSeed, error)

ReadShootedSeed determines whether the Shoot has been marked to be registered automatically as a Seed cluster.

type ShootedSeedAPIServer

type ShootedSeedAPIServer struct {
	Replicas   *int32
	Autoscaler *ShootedSeedAPIServerAutoscaler
}

func ReadManagedSeedAPIServer added in v1.18.0

func ReadManagedSeedAPIServer(shoot *gardencorev1beta1.Shoot) (*ShootedSeedAPIServer, error)

ReadManagedSeedAPIServer reads the managed seed API server settings from the corresponding annotation.

type ShootedSeedAPIServerAutoscaler

type ShootedSeedAPIServerAutoscaler struct {
	MinReplicas *int32
	MaxReplicas int32
}

type ShootedSeedResources added in v1.13.0

type ShootedSeedResources struct {
	Capacity corev1.ResourceList
	Reserved corev1.ResourceList
}

type VersionPredicate added in v1.4.0

type VersionPredicate func(expirableVersion gardencorev1beta1.ExpirableVersion, version *semver.Version) (bool, error)

func FilterDifferentMajorMinorVersion added in v1.4.0

func FilterDifferentMajorMinorVersion(currentSemVerVersion semver.Version) VersionPredicate

FilterDifferentMajorMinorVersion returns a VersionPredicate(closure) that evaluates whether a given version v has a different same major.minor version compared to the currentSemVerVersion returns true if v has a different major.minor version

func FilterLowerVersion added in v1.4.0

func FilterLowerVersion(currentSemVerVersion semver.Version) VersionPredicate

FilterLowerVersion returns a VersionPredicate(closure) that evaluates whether a given version v is lower than the currentSemVerVersion returns true if it is lower

func FilterNonConsecutiveMinorVersion added in v1.4.0

func FilterNonConsecutiveMinorVersion(currentSemVerVersion semver.Version) VersionPredicate

FilterNonConsecutiveMinorVersion returns a VersionPredicate(closure) that evaluates whether a given version v has a consecutive minor version compared to the currentSemVerVersion returns true if v does not have a consecutive minor version

func FilterSameVersion added in v1.4.0

func FilterSameVersion(currentSemVerVersion semver.Version) VersionPredicate

FilterSameVersion returns a VersionPredicate(closure) that evaluates whether a given version v is equal to the currentSemVerVersion returns true if it is equal

type WrappedLastErrors

type WrappedLastErrors struct {
	Description string
	LastErrors  []gardencorev1beta1.LastError
}

WrappedLastErrors is a structure which contains the general description of the lastErrors which occurred and an array of all lastErrors

func NewWrappedLastErrors

func NewWrappedLastErrors(description string, err error) *WrappedLastErrors

NewWrappedLastErrors returns an error

Jump to

Keyboard shortcuts

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