utils

package
v0.3.13-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils offers functions of general utility in other parts of the system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationMillSeconds added in v0.3.1

func DurationMillSeconds(d time.Duration) string

DurationMillSeconds returns the duration is milliseconds (e.g. "15ms")

func DurationSeconds added in v0.3.0

func DurationSeconds(d time.Duration) string

DurationSeconds returns the duration is seconds with a precession of 2 decimals, removing trailing zeros (e.g. "1.5s")

func FindPort added in v0.3.10

func FindPort(port intstr.IntOrString, pod corev1.Pod) (intstr.IntOrString, error)

FindPort returns the port in the Pod that maps to the given port by port number or name

func GetBooleanEnvVar added in v0.3.4

func GetBooleanEnvVar(envVar string, defaultValue bool) bool

GetBooleanEnvVar returns a boolean environment variable. If variable is not set or invalid value, returns the default value

func GetInt32EnvVar added in v0.3.8

func GetInt32EnvVar(envVar string, defaultValue int32) int32

GetInt32EnvVar returns an integer environment variable. If variable is not set or invalid value, returns the default value

func GetStringEnvVar added in v0.3.8

func GetStringEnvVar(envVar string, defaultValue string) string

GetStringEnvVar returns a string environment variable. If variable is not set returns the default value

func GetTargetPort added in v0.3.10

func GetTargetPort(service corev1.Service, svcPort intstr.IntOrString) (intstr.IntOrString, error)

GetTargetPort returns the target port for the given service port

func HasHostNetwork added in v0.3.4

func HasHostNetwork(pod corev1.Pod) bool

HasHostNetwork returns whether a pod has HostNetwork enabled, i.e. it shares the host's network namespace.

func PodIP added in v0.3.4

func PodIP(pod corev1.Pod) (string, error)

PodIP returns the pod IP for the supplied pod, or an error if it has no IP (yet).

func PodNames added in v0.3.10

func PodNames(pods []corev1.Pod) []string

PodNames return the name of the pods in a list

func Retry

func Retry(timeout time.Duration, backoff time.Duration, f func() (bool, error)) error

Retry retries a function until it returns true, error, or the timeout expires. If the function returns false, a new attempt is tried after the backoff period

func Sample added in v0.3.10

func Sample(pods []corev1.Pod, count intstr.IntOrString) ([]corev1.Pod, error)

Sample a subset of the given list of Pods. The count is defined as a int or a string representing a percentage. If the count is a percentage and there are no enough elements in the pod list, the number is rounded up. If the list is not empty, at least one element is returned For example 25% of a list of 2 pods will return one pod.

Types

This section is empty.

Jump to

Keyboard shortcuts

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