utils

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 7 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 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 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 HasPort added in v0.3.4

func HasPort(pod corev1.Pod, port uint) bool

HasPort verifies if a pods listen to the given port

func MapPort added in v0.3.4

func MapPort(service corev1.Service, port uint, pod corev1.Pod) (uint, error)

MapPort returns the port in the Pod that maps to the given service port

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 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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