Documentation ¶
Index ¶
- Constants
- func AnyBoolTrue(values ...bool) bool
- func BoolToPointer(b bool) *bool
- func CreateCertificateAuthority() *x509.Certificate
- func CreateClientCertificate(name string) *x509.Certificate
- func CurrentNamespace() (string, error)
- 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 HashBytes(b []byte) string
- func Indent(s string, n int) string
- func Int32ToPointer(i int32) *int32
- func Int64ToPointer(i int64) *int64
- func MustCreateDirectory(directory string, permissions fs.FileMode)
- func MustCurrentNamespace() string
- func MustFileExists(f string) bool
- func MustGeneratePrivateKey(keySize int) *rsa.PrivateKey
- func MustNewManager(scheme *apimachineryruntime.Scheme) ctrlruntime.Manager
- 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 ResolveAtFileOrURL(path string) ([]byte, error)
- func SafeConcatNameKubernetes(name ...string) string
- func SafeConcatNameMax(name []string, max int) string
- func SignalHandledContext(logf func(f string, a ...interface{})) context.Context
- func StringSliceContains(ss []string, val string) bool
- func StringSliceDifference(a, b []string) []string
- func StringToPointer(s string) *string
- type CertData
- type StringSet
Constants ¶
const (
// NameMaxLen is the maximum length for a kubernetes name.
NameMaxLen = 63
)
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 CurrentNamespace ¶
CurrentNamespace returns the current kubernetes namespace as read from the KUBE_NAMESPACE env var, or the serviceaccount/namespace file on the instance.
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 HashBytes ¶
HashBytes accepts a bytes object and returns a string sha256 hash representing that object.
func MustCreateDirectory ¶
MustCreateDirectory creates a directory at path `directory` with provided permissions, it panics if an error is encountered.
func MustCurrentNamespace ¶
func MustCurrentNamespace() string
MustCurrentNamespace returns the current kubernetes namespace or panics.
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 MustNewManager ¶
func MustNewManager(scheme *apimachineryruntime.Scheme) ctrlruntime.Manager
MustNewManager returns a new controller-runtime Manager 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 ResolveAtFileOrURL ¶
ResolveAtFileOrURL returns the bytes from `path` where path is either a filepath or URL.
func SafeConcatNameKubernetes ¶
SafeConcatNameKubernetes concats all provided strings into a string joined by "-" - if the final string is greater than 63 characters, the string will be shortened, and a hash will be used at the end of the string to keep it unique, but safely within allowed lengths.
func SafeConcatNameMax ¶
SafeConcatNameMax concats all provided strings into a string joined by "-" - if the final string is greater than max characters, the string will be shortened, and a hash will be used at the end of the string to keep it unique, but safely within allowed lengths.
func SignalHandledContext ¶
SignalHandledContext returns a context that will be canceled if a SIGINT or SIGTERM is received.
func StringSliceContains ¶
StringSliceContains returns true if the value val is in the 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 StringToPointer ¶ added in v0.0.7
StringToPointer returns a pointer to s.
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 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.