common

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package common provides common utility functions to all packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendStringIfMissing

func AppendStringIfMissing(sl []string, s ...string) []string

AppendStringIfMissing will append the given element(s) to the slice only if they are not already present.

func BoolPointer

func BoolPointer(b bool) *bool

BoolPointer returns a pointer to the given boolean

func GeneratePassword

func GeneratePassword(length int) (string, error)

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

func HashPassword(passw string) (string, error)

HashPassword creates a salt from a password for storing in a database

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to the given int32

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr returns a pointer to the given int64

func ParseFlagsAndSetupLogging

func ParseFlagsAndSetupLogging()

ParseFlagsAndSetupLogging is a utility function to setup logging and parse any provided flags.

func PasswordMatchesHash

func PasswordMatchesHash(passw, hash string) bool

PasswordMatchesHash returns true if the given password matches the given salt.

func PrintVersion

func PrintVersion(log logr.Logger)

PrintVersion will dump version info to the given log interface.

func Retry

func Retry(attempts int, sleep time.Duration, f func() error) error

Retry will retry the given function until either the maximum attempts is reached or a stop error is returned.

func StringSliceContains

func StringSliceContains(ss []string, s string) bool

StringSliceContains returns true if the given string exists in the given slice.

func StringSliceRemove

func StringSliceRemove(ss []string, s string) []string

StringSliceRemove returns a new slice with the given element removed.

func TarDirectoryToTempFile

func TarDirectoryToTempFile(srcPath string) (string, error)

TarDirectoryToTempFile will create a gzipped tarball of the given directory, write it to a tempfile, and return the path to the file.

Types

type StopRetry

type StopRetry struct{ Err error }

StopRetry is returned to tell the Retry function to stop retrying.

func (*StopRetry) Error

func (s *StopRetry) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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