Documentation ¶
Overview ¶
Package common provides common utility functions to all packages
Index ¶
- func AppendStringIfMissing(sl []string, s ...string) []string
- func BoolPointer(b bool) *bool
- func GeneratePassword(length int) (string, error)
- func GetClusterSuffix() string
- func HashPassword(passw string) (string, error)
- func Int32Ptr(i int32) *int32
- func Int64Ptr(i int64) *int64
- func ParseFlagsAndSetupLogging()
- func PasswordMatchesHash(passw, hash string) bool
- func PrintVersion(log logr.Logger)
- func Retry(attempts int, sleep time.Duration, f func() error) error
- func StringSliceContains(ss []string, s string) bool
- func StringSliceRemove(ss []string, s string) []string
- func TarDirectoryToTempFile(srcPath string) (string, error)
- type StopRetry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendStringIfMissing ¶
AppendStringIfMissing will append the given element(s) to the slice only if they are not already present.
func BoolPointer ¶
BoolPointer returns a pointer to the given boolean
func GeneratePassword ¶
GeneratePassword generates a password with the given length
func GetClusterSuffix ¶
func GetClusterSuffix() string
GetClusterSuffix returns the cluster suffix as parsed from the resolvconf. If we cannot read the file we return an empty string. This is a safeguard against irregular short-name resolution inside different cluster setups.
func HashPassword ¶
HashPassword creates a salt from a password for storing in a database
func ParseFlagsAndSetupLogging ¶
func ParseFlagsAndSetupLogging()
ParseFlagsAndSetupLogging is a utility function to setup logging and parse any provided flags.
func PasswordMatchesHash ¶
PasswordMatchesHash returns true if the given password matches the given salt.
func PrintVersion ¶
PrintVersion will dump version info to the given log interface.
func Retry ¶
Retry will retry the given function until either the maximum attempts is reached or a stop error is returned.
func StringSliceContains ¶
StringSliceContains returns true if the given string exists in the given slice.
func StringSliceRemove ¶
StringSliceRemove returns a new slice with the given element removed.
func TarDirectoryToTempFile ¶
TarDirectoryToTempFile will create a gzipped tarball of the given directory, write it to a tempfile, and return the path to the file.