util

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool2Int added in v1.8.1

func Bool2Int(flag bool) int

Bool2Int converts bool to int

func Coalesce

func Coalesce(val, defaultVal string) string

Coalesce returns the first argument if it is not null, otherwise the second one.

func CoalesceBool added in v1.5.0

func CoalesceBool(val, defaultVal *bool) *bool

CoalesceBool works like coalesce but for *bool

func CoalesceDuration added in v1.6.0

func CoalesceDuration(val time.Duration, defaultVal string) time.Duration

CoalesceDuration works like coalesce but for time.Duration

func CoalesceInt added in v1.6.0

func CoalesceInt(val, defaultVal int) int

CoalesceInt works like coalesce but for int

func CoalesceInt32 added in v1.5.0

func CoalesceInt32(val, defaultVal *int32) *int32

CoalesceInt32 works like coalesce but for *int32

func CoalesceInt64 added in v1.6.1

func CoalesceInt64(val, defaultVal int64) int64

CoalesceInt64 works like coalesce but for int64

func CoalesceStrArr added in v1.6.0

func CoalesceStrArr(val, defaultVal []string) []string

CoalesceStrArr returns the first argument if it is not null, otherwise the second one.

func CoalesceStrMap added in v1.6.0

func CoalesceStrMap(val, defaultVal map[string]string) map[string]string

CoalesceStrMap returns the first argument if it is not null, otherwise the second one.

func CoalesceUInt32 added in v1.6.0

func CoalesceUInt32(val, defaultVal uint32) uint32

CoalesceUInt32 works like coalesce but for uint32

func Diff

func Diff(a, b interface{}) []string

Diff returns diffs between 2 objects

func False added in v1.2.0

func False() *bool

func FindNamedStringSubmatch

func FindNamedStringSubmatch(r *regexp.Regexp, s string) map[string]string

FindNamedStringSubmatch returns a map of strings holding the text of the matches of the r regular expression

func IsEqualIgnoreOrder added in v1.6.0

func IsEqualIgnoreOrder(a, b []string) bool

Compare two string slices while ignoring the order of elements

func IsSmallerQuantity added in v1.3.0

func IsSmallerQuantity(requestStr, limitStr string) (bool, error)

IsSmallerQuantity : checks if first resource is of a smaller quantity than the second

func MapContains

func MapContains(haystack, needle map[string]string) bool

MapContains returns true if and only if haystack contains all the keys from the needle with matching corresponding values

func MaxInt32 added in v1.5.0

func MaxInt32(a, b *int32) *int32

MaxInt32 : Return maximum of two integers provided via pointers. If one value is not defined, return the other one. If both are not defined, result is also undefined, caller needs to check for that.

func MinResource added in v1.9.0

func MinResource(maxRequestStr, requestStr string) (resource.Quantity, error)

func NameFromMeta

func NameFromMeta(meta metav1.ObjectMeta) spec.NamespacedName

NameFromMeta converts a metadata object to the NamespacedName name representation.

func PrettyDiff

func PrettyDiff(a, b interface{}) string

PrettyDiff shows the diff between 2 objects in an easy to understand format. It is mainly used for debugging output.

func RandomPassword

func RandomPassword(n int) string

RandomPassword generates a secure, random alphanumeric password of a given length.

func RemoveString added in v1.11.0

func RemoveString(slice []string, s string) (result []string)

Iterate through slice and remove certain string, then return cleaned slice

func SliceContains added in v1.6.0

func SliceContains(slice interface{}, item interface{}) bool

SliceContains

func StringSliceReplaceElement added in v1.6.3

func StringSliceReplaceElement(s []string, a, b string) (result []string)

SliceReplaceElement

func SubstractStringSlices

func SubstractStringSlices(a []string, b []string) (result []string, equal bool)

SubstractStringSlices finds elements in a that are not in b and return them as a result slice.

func ToIntStr added in v1.8.0

func ToIntStr(val int) *intstr.IntOrString

ToIntStr converts int to IntOrString type

func True added in v1.2.0

func True() *bool

helper function to get bool pointers

Types

type Encryptor added in v1.6.0

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

func NewEncryptor added in v1.6.0

func NewEncryptor(encryption string) *Encryptor

func (*Encryptor) PGUserPassword added in v1.6.0

func (e *Encryptor) PGUserPassword(user spec.PgUser) string

func (*Encryptor) PGUserPasswordMD5 added in v1.6.0

func (e *Encryptor) PGUserPasswordMD5(user spec.PgUser) string

func (*Encryptor) PGUserPasswordScramSHA256 added in v1.6.0

func (e *Encryptor) PGUserPasswordScramSHA256(user spec.PgUser) string

type Hasher added in v1.6.0

type Hasher func(user spec.PgUser) string

type Random added in v1.6.0

type Random func(n int) string

Directories

Path Synopsis
Package diff implements a linewise diff algorithm.
Package diff implements a linewise diff algorithm.

Jump to

Keyboard shortcuts

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