util

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 12 Imported by: 27

Documentation

Index

Constants

View Source
const (
	KubernetesSecret  string = "KubernetesSecret"
	AWSSecretsManager string = "AWSSecretsManager"
	AWSSystemManager  string = "AWSSystemManager"
	HashiCorpVault    string = "HashiCorpVault"
)

Variables

This section is empty.

Functions

func AppendErrorString

func AppendErrorString(errs []string, err error) []string

func Close

func Close(c Closer, logger *zap.SugaredLogger)

func ComputeHash

func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) string

ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.

func ContainsString

func ContainsString(list []string, element string) bool

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

func ExtractChartVersion

func ExtractChartVersion(chartVersion string) (int, int, error)

func GetErrorOrNil

func GetErrorOrNil(errs []string) error

func Int

func Int() int

Int returns a non-negative pseudo-random int.

func Int63nRange

func Int63nRange(min, max int64) int64

IntnRange generates an int64 integer in range [min,max). By design this should panic if input is invalid, <= 0.

func Intn

func Intn(max int) int

Intn generates an integer in range [0,max). By design this should panic if input is invalid, <= 0.

func IntnRange

func IntnRange(min, max int) int

IntnRange generates an integer in range [min,max). By design this should panic if input is invalid, <= 0.

func Perm

func Perm(n int) []int

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n) from the default Source.

func SafeEncodeString

func SafeEncodeString(s string) string

SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and ensures that strings generated from hash functions appear consistent throughout the API.

func Seed

func Seed(seed int64)

Seed seeds the rng with the provided seed.

func String

func String(n int) string

String generates a random alphanumeric string, without vowels, which is n characters long. This will panic if n is less than zero. How the random string is created: - we generate random int63's - from each int63, we are extracting multiple random letters by bit-shifting and masking - if some index is out of range of alphanums we neglect it (unlikely to happen multiple times in a row)

Types

type Closer

type Closer interface {
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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