Documentation ¶
Index ¶
- func AnyBoolTrue(values ...bool) bool
- func CreateCertificateAuthority() *x509.Certificate
- func CreateClientCertificate(name string) *x509.Certificate
- func GetEnvBoolOrDefault(k string, d bool) bool
- func GetEnvFloat64OrDefault(k string, d float64) float64
- func GetEnvIntOrDefault(k string, d int) int
- func GetEnvStrOrDefault(k, d string) string
- func GitHubGroupAndRepoFromURL(path string) (group, repo string)
- func GitHubNormalToRawLink(path string) string
- func HashBytes(b []byte) string
- func HashObject(o any) ([]byte, string, error)
- func HashObjectYAML(o any) ([]byte, string, error)
- func Indent(s string, n int) string
- func IsURL(path string) bool
- func MustCreateDirectory(directory string, permissions fs.FileMode)
- func MustFileExists(f string) bool
- func MustGeneratePrivateKey(keySize int) *rsa.PrivateKey
- func MustSetupWithManager(setup func(mgr ctrlruntime.Manager) error, mgr ctrlruntime.Manager)
- func Panic(msg string)
- func RandomString(length int) string
- func RegexStringSubMatchToMap(p *regexp.Regexp, s string) map[string]string
- func SignalHandledContext(logf func(f string, a ...interface{})) (context.Context, context.CancelFunc)
- func StringSliceContainsAll(ss, vals []string) bool
- func StringSliceDifference(a, b []string) []string
- func StringSliceEqual(a, b []string) bool
- func ToPointer[T any](t T) *T
- func UnifiedDiff(a, b any) (string, error)
- func WriteHTTPContentsFromPath(ctx context.Context, path string, w io.Writer, headerData map[string]string) error
- type CertData
- type ObjectDiffer
- type StringSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyBoolTrue ¶
AnyBoolTrue returns True if any of the provided bool values is True.
func CreateCertificateAuthority ¶
func CreateCertificateAuthority() *x509.Certificate
CreateCertificateAuthority generates a certificate authority x509.Certificate.
func CreateClientCertificate ¶
func CreateClientCertificate(name string) *x509.Certificate
CreateClientCertificate generates a client x509.Certificate with the common name provided.
func GetEnvBoolOrDefault ¶
GetEnvBoolOrDefault returns true if the environment variable is set, or the default d if it is unset.
func GetEnvFloat64OrDefault ¶
GetEnvFloat64OrDefault returns the value of the environment variable k as a float *or* the default d if casting fails or the environment variable is not set.
func GetEnvIntOrDefault ¶
GetEnvIntOrDefault returns the value of the environment variable k as an int *or* the default d if casting fails or the environment variable is not set.
func GetEnvStrOrDefault ¶
GetEnvStrOrDefault returns the value of the environment variable k as a string *or* the default d if casting fails or the environment variable is not set.
func GitHubGroupAndRepoFromURL ¶ added in v0.0.17
GitHubGroupAndRepoFromURL attempts to return the GitHub group/user and repository from a GitHub URL.
func GitHubNormalToRawLink ¶ added in v0.0.17
GitHubNormalToRawLink try to convert a "normal" github link to a raw link.
func HashBytes ¶
HashBytes accepts a bytes object and returns a string sha256 hash representing that object.
func HashObject ¶ added in v0.0.17
HashObject accepts any object, dumps it to json then sends it to HashBytes.
func HashObjectYAML ¶ added in v0.0.17
HashObjectYAML accepts any object, dumps it to yaml then sends it to HashBytes.
func IsURL ¶ added in v0.0.17
IsURL returns true if the given path string starts with http or https.
func MustCreateDirectory ¶
MustCreateDirectory creates a directory at path `directory` with provided permissions, it panics if an error is encountered.
func MustFileExists ¶
MustFileExists returns true if a given file exists, otherwise false, it panics if any error is encountered.
func MustGeneratePrivateKey ¶
func MustGeneratePrivateKey(keySize int) *rsa.PrivateKey
MustGeneratePrivateKey generates a rsa private key of keySize or panics.
func MustSetupWithManager ¶
func MustSetupWithManager(setup func(mgr ctrlruntime.Manager) error, mgr ctrlruntime.Manager)
MustSetupWithManager simply panics if registering a controller to the manager fails.
func Panic ¶
func Panic(msg string)
Panic tries to panic "nicely" but will send a second sigint to really kill the process if the first does not succeed within a second, and if for some reason that one does not kill it, we try a sigkill, and finally if that still didn't work, we will simply panic outright.
func RandomString ¶
RandomString returns a string of random alphabet characters `length` long.
func RegexStringSubMatchToMap ¶
RegexStringSubMatchToMap accepts a regexp pattern and a string and returns a mapping of named capture groups to their found value. Obviously this only works with named capture groups.
func SignalHandledContext ¶
func SignalHandledContext( logf func(f string, a ...interface{}), ) (context.Context, context.CancelFunc)
SignalHandledContext returns a context that will be canceled if a SIGINT or SIGTERM is received.
func StringSliceContainsAll ¶ added in v0.0.17
StringSliceContainsAll returns true if all values in vals are in string slice ss, otherwise false.
func StringSliceDifference ¶
StringSliceDifference returns the difference between a and b string slices. Items that exist in slice "b" but are missing in slice "a" will be returned.
func StringSliceEqual ¶ added in v0.0.17
StringSliceEqual returns true if the string slices provided are equal, otherwise false.
func ToPointer ¶ added in v0.0.17
func ToPointer[T any](t T) *T
ToPointer accepts an object T and returns a pointer to it.
func UnifiedDiff ¶ added in v0.0.17
UnifiedDiff accepts a and b as any, dumps them to json then returns a unified diff from difflibgo.
Types ¶
type CertData ¶
CertData is a struct that holds certificate information.
func GenerateCertificateData ¶
func GenerateCertificateData(certBytes, caBytes []byte, key *rsa.PrivateKey) (*CertData, error)
GenerateCertificateData generates certificate data (ready to be written to disk) from the given cert/ca bytes and key.
type ObjectDiffer ¶ added in v0.0.17
type ObjectDiffer[T any] struct { // Current objects by endpoint name Current map[string]T // Missing objects by endpoint name Missing []string // Extra objects that should be pruned Extra []T }
ObjectDiffer holds objets of type T -- used for comparing current, missing, and extraneous objects in the cluster.
func (*ObjectDiffer[T]) CurrentObjectNames ¶ added in v0.0.17
func (d *ObjectDiffer[T]) CurrentObjectNames() []string
CurrentObjectNames returns a slice of the names of the current objects.
func (*ObjectDiffer[T]) SetExtra ¶ added in v0.0.17
func (d *ObjectDiffer[T]) SetExtra(allExpectedNames []string)
SetExtra sets the extra objects based on the slice of all expected object names and the current objects -- `Current` must be set prior to calling this or things will be weird.
func (*ObjectDiffer[T]) SetMissing ¶ added in v0.0.17
func (d *ObjectDiffer[T]) SetMissing(allExpectedNames []string)
SetMissing sets the missing objects based on the slice of all expected object names.
type StringSet ¶
type StringSet interface { Add(s string) Extend(sSlice []string) Remove(s string) Contains(s string) bool Len() int Items() []string }
StringSet defines a simple string set interface.
func NewStringSet ¶
func NewStringSet() StringSet
NewStringSet returns an object satisfying the StringSet interface.
func NewStringSetWithValues ¶
NewStringSetWithValues returns an object satisfying the StringSet interface with the given values pre-loaded to the set.