util

package
v0.0.0-...-3cf8ccf Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangedAfter

func ChangedAfter(obj client.Object, mutateFn func() error) bool

func ConfigMapVolume

func ConfigMapVolume(name string) corev1.VolumeSource

func EnvVarKey

func EnvVarKey(v corev1.EnvVar) string

func FieldRefEnv

func FieldRefEnv(key string, field string) corev1.EnvVar

func FindFirst

func FindFirst[E any](list []E, predicate Predicate[E]) *E

func GetContainersReadyCondition

func GetContainersReadyCondition(status v1.PodStatus) *v1.PodCondition

GetContainersReadyCondition extracts the containers ready condition from the given status and returns that. Returns nil if the condition is not present.

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func Ignore

func Ignore(isErr func(error) bool, err error) error

func IsContainersReadyConditionTrue

func IsContainersReadyConditionTrue(status v1.PodStatus) bool

IsContainersReadyConditionTrue returns true if a pod is ready; false otherwise.

func IsFound

func IsFound(err error) (error, bool)

func IsPodAvailable

func IsPodAvailable(pod *v1.Pod, minReadySeconds int32, now metav1.Time) bool

IsPodAvailable returns true if a pod is available; false otherwise. Precondition for an available pod is that it must be ready. On top of that, there are two cases when a pod can be considered available: 1. minReadySeconds == 0, or 2. LastTransitionTime (is set) + minReadySeconds < current time

func IsPodPhaseTerminal

func IsPodPhaseTerminal(phase v1.PodPhase) bool

IsPhaseTerminal returns true if the pod's phase is terminal.

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.

func IsPodTerminal

func IsPodTerminal(pod *v1.Pod) bool

IsPodTerminal returns true if a pod is terminal, all containers are stopped and cannot ever regress.

func PodOrdinal

func PodOrdinal(name string) (int, error)

func Upsert

func Upsert[E comparable](list []E, elem E) []E

func UpsertByKey

func UpsertByKey[K comparable, V any](list []V, elem V, keyFunc func(V) K) []V

UpsertByKey insert an element to the list or update an existing element in list with same key. UpsertByKey assumes the no duplicate key and will only update the first element with the same key if there are duplicate keys in the list.

func WasDeleted

func WasDeleted(obj client.Object) bool

Types

type Predicate

type Predicate[E any] func(E) bool

func WithVolumeName

func WithVolumeName(name string) Predicate[corev1.Volume]

Jump to

Keyboard shortcuts

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