utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlowStartInitialBatchSize = 1
)

Variables

View Source
var (
	EnvPodNamespaceVal = os.Getenv("POD_NAMESPACE")
	EnvPodNameVal      = os.Getenv("POD_NAME")
	EnvPodIpVal        = os.Getenv("POD_IP")
)

Functions

func CombineLabelSelectors

func CombineLabelSelectors(ls ...labels.Selector) labels.Selector

func DumpJSON

func DumpJSON(o interface{}) string

DumpJSON returns the JSON encoding

func GetCertDir

func GetCertDir() string

func GetCertWriter

func GetCertWriter() string

func GetContainerEnvVar

func GetContainerEnvVar(container *v1.Container, key string) *v1.EnvVar

func GetHost

func GetHost() string

func GetMD5Hash

func GetMD5Hash(text string) string

func GetNamespace

func GetNamespace() string

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 GetPort

func GetPort() int

func GetSecretName

func GetSecretName() string

func GetServiceName

func GetServiceName() string

func Init

func Init() error

func InitFlags

func InitFlags(flagset *flag.FlagSet)

func IsHashChangedError

func IsHashChangedError(err error) bool

func IsPodActive

func IsPodActive(p *v1.Pod) bool

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 Key

func Key(namespace, name string) string

func KeyFunc

func KeyFunc(obj metav1.Object) string

func LastReplace

func LastReplace(s, old, new string) string

func MergeLabelSelector

func MergeLabelSelector(selA, selB *metav1.LabelSelector) *metav1.LabelSelector

func NegateLabelSelector

func NegateLabelSelector(sel *metav1.LabelSelector) *metav1.LabelSelector

func NewClientFromManager

func NewClientFromManager(mgr manager.Manager, name string) client.Client

func NewDirectorClientFromManager

func NewDirectorClientFromManager(mgr manager.Manager, name string) client.Client

func SlowStartBatch

func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error, maxBatchSize int) (int, error)

SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.

It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.

If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.

It returns the number of successful calls to the function.

func ValidatedLabelSelectorAsSelector

func ValidatedLabelSelectorAsSelector(ps *metav1.LabelSelector) (labels.Selector, error)

Types

type HashChangedError

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

func (HashChangedError) Error

func (e HashChangedError) Error() string

func (HashChangedError) String

func (e HashChangedError) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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