util

package
v1.67.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PodNamespace           string = os.Getenv("POD_NAMESPACE")
	KotsadmTargetNamespace string = os.Getenv("KOTSADM_TARGET_NAMESPACE")
)

Functions

func AppNamespace

func AppNamespace() string

func CommonSlicePrefix

func CommonSlicePrefix(first []string, second []string) []string

func CompareStringArrays

func CompareStringArrays(arr1, arr2 []string) bool

CompareStringArrays returns true if all elements in arr1 are present in arr2 and the other way around. it does not check for equal counts of duplicates, or for ordering.

func ConvertToSingleDocs

func ConvertToSingleDocs(doc []byte) [][]byte

func ExtractTGZArchive

func ExtractTGZArchive(tgzFile string, destDir string) error

func GenPassword

func GenPassword(length int) string

generates a [0-9a-zA-Z] password of the specified length

func IntPointer

func IntPointer(x int) *int64

func IsURL

func IsURL(str string) bool

func MarshalIndent

func MarshalIndent(indent int, in interface{}) ([]byte, error)

func NewThrottle

func NewThrottle(after time.Duration) func(f func())

func SplitStringOnLen

func SplitStringOnLen(str string, maxLength int) ([]string, error)

Types

type ActionableError

type ActionableError struct {
	NoRetry bool
	Message string
}

func (ActionableError) Error

func (e ActionableError) Error() string

type ErrorBackoff added in v1.38.0

type ErrorBackoff struct {
	MinPeriod time.Duration
	MaxPeriod time.Duration
	// contains filtered or unexported fields
}

ErrorBackoff keeps track of last time an error was logged to prevent duplicating the OnError function. Errors are considered the same if the error text matches exactly. Only last error is remembered, so if error changes every time, every OnError function will be executed. The period is doubled every time OnError is called until the max period is reached.

func (*ErrorBackoff) OnError added in v1.38.0

func (r *ErrorBackoff) OnError(err error, fn func())

Jump to

Keyboard shortcuts

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