utils

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 8 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayEqual added in v1.1.0

func ArrayEqual(a, b []string) bool

ArrayEqual tells whether a and b contain the same elements at the same index. A nil argument is equivalent to an empty slice.

func ArrayEqualElements added in v1.1.0

func ArrayEqualElements(a, b []string) bool

ArrayEqualElements tells whether a and b contain the same elements. Elements does not need to be in same index A nil argument is equivalent to an empty slice.

func BoolPtr added in v1.1.0

func BoolPtr(value bool) *bool

BoolPtr returns a pointer to the passed bool. Deprecated - use pointers.Ptr

func ContainsString added in v1.1.0

func ContainsString(s []string, e string) bool

ContainsString return if a string is contained in the slice

func EqualStringLists

func EqualStringLists(list1, list2 []string) bool

EqualStringLists Compare two string lists

func EqualStringMaps

func EqualStringMaps(map1, map2 map[string]string) bool

EqualStringMaps Compare two string maps

func EqualStringsAsPtr

func EqualStringsAsPtr(s1, s2 *string) bool

func FormatTime added in v1.1.0

func FormatTime(time *metav1.Time) string

FormatTime Converts kubernetes time to formatted timestamp

func FormatTimestamp added in v1.1.0

func FormatTimestamp(timestamp time.Time) string

FormatTimestamp Converts time to formatted timestamp

func GenerateRandomKey added in v1.1.9

func GenerateRandomKey(length int) []byte

GenerateRandomKey generates a cryptographically secure random key

func IsNil added in v1.2.1

func IsNil(obj interface{}) bool

IsNil check if the object is nil or an interface pointer contain nil

func ParseTimestamp added in v1.1.0

func ParseTimestamp(timestamp string) (time.Time, error)

ParseTimestamp Converts timestamp to time by RFC3339 layout

func ParseTimestampBy added in v1.1.1

func ParseTimestampBy(layout, timestamp string) (time.Time, error)

ParseTimestampBy Converts timestamp to time by custom layout

func ParseTimestampNillable added in v1.1.0

func ParseTimestampNillable(timestamp string) *time.Time

ParseTimestampNillable Converts timestamp to time or nil

func RandString added in v1.1.0

func RandString(length int) string

RandString Returns a random string of given length

func RandStringSeed added in v1.1.0

func RandStringSeed(length int, src rand.Source) string

RandStringSeed Returns a random string of given length from seed

func RandStringStrSeed added in v1.1.0

func RandStringStrSeed(length int, src string) string

RandStringStrSeed Returns a random string of given length from seed

func ShortenString

func ShortenString(s string, charsToCut int) string

ShortenString Get string without n-last chars

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the passed string.

func StringUnPtr added in v1.1.7

func StringUnPtr(s *string) string

StringUnPtr returns a string from a string pointer.

func StringUnPtrDefault added in v1.1.7

func StringUnPtrDefault(s *string, defaultValue string) string

StringUnPtrDefault returns a string from a string pointer, or default value, if nil.

func TernaryString

func TernaryString(condition bool, trueValue, falseValue string) string

TernaryString operator

func ToLowerCase added in v1.1.0

func ToLowerCase(slice []string) []string

ToLowerCase Convert all strings in a list to lower case

Types

type Clock added in v1.1.0

type Clock interface {
	Now() time.Time
}

type FakeClock added in v1.1.0

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

func NewFakeClock added in v1.1.0

func NewFakeClock(now time.Time) *FakeClock

func (*FakeClock) Now added in v1.1.0

func (c *FakeClock) Now() time.Time

type RealClock added in v1.1.0

type RealClock struct{}

func (RealClock) Now added in v1.1.0

func (c RealClock) Now() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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