Documentation ¶
Index ¶
- func CompareVersions(version1, operator, version2 string) (bool, error)
- func ComputeSHA1Hex(in []byte) string
- func ComputeSHA256Hex(in []byte) string
- func ConvertJSONToMap(input []byte) *jsonq.JsonQuery
- func CreateSHA1Secret(username, password []byte) string
- func DecodeBase64(in string) ([]byte, error)
- func DecodeCertificate(bytes []byte) (*x509.Certificate, error)
- func DecodePrivateKey(bytes []byte) (*rsa.PrivateKey, error)
- func EncodeBase64(in []byte) string
- func EncodeCertificate(certificate []byte) []byte
- func EncodePrivateKey(key *rsa.PrivateKey) []byte
- func EncodeSHA1(in []byte) string
- func FindFreePort() (int, error)
- func FuncName(f interface{}) string
- func GenerateRandomString(n int) string
- func GenerateRandomStringFromCharset(n int, allowedCharacters string) string
- func LookupDNS(domain string) []string
- func MergeMaps(defaults, custom map[string]interface{}) map[string]interface{}
- func RenderLocalTemplate(tpl string, values interface{}) ([]byte, error)
- func RenderTemplate(filename string, values interface{}) ([]byte, error)
- func RenderTemplateWithFuncs(filename string, funcs template.FuncMap, values interface{}) ([]byte, error)
- func RenderTemplatesWithFuncs(filenames []string, funcs template.FuncMap, values interface{}) ([]byte, error)
- func Retry(logger *logrus.Entry, maxWaitTime time.Duration, f func() (bool, error)) error
- func RetryFunc(f func() error) func() (bool, error)
- func SHA1(in []byte) []byte
- func SHA256(in []byte) []byte
- func TestEmail(email string) bool
- func TimeElapsed(timestamp *metav1.Time, duration time.Duration) bool
- func ValueExists(value string, list []string) bool
- func WaitUntilDNSNameResolvable(domain string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions returns true if the constraint <version1> compared by <operator> to <version2> returns true, and false otherwise. The comparison is based on semantic versions, i.e. <version1> and <version2> will be converted if needed.
func ComputeSHA1Hex ¶
ComputeSHA1Hex computes the hexadecimal representation of the SHA1 hash of the given input byte slice <in>, converts it to a string and returns it (length of returned string is 40 characters).
func ComputeSHA256Hex ¶
ComputeSHA256Hex computes the hexadecimal representation of the SHA256 hash of the given input byte slice <in>, converts it to a string and returns it.
func ConvertJSONToMap ¶
ConvertJSONToMap parses a byte slice containing valid JSON and returns a JsonQuery object which can be used to access arbitrary keys/fields in the JSON. See https://github.com/jmoiron/jsonq for detailed information how to access the values.
func CreateSHA1Secret ¶
CreateSHA1Secret takes a username and a password and returns a sha1-schemed credentials pair as string.
func DecodeBase64 ¶
DecodeBase64 takes a Base64-encoded string and returns the decoded byte slice.
func DecodeCertificate ¶
func DecodeCertificate(bytes []byte) (*x509.Certificate, error)
DecodeCertificate takes a byte slice, decodes it from the PEM format, converts it to an x509.Certificate object, and returns it. In case an error occurs, it returns the error.
func DecodePrivateKey ¶
func DecodePrivateKey(bytes []byte) (*rsa.PrivateKey, error)
DecodePrivateKey takes a byte slice, decodes it from the PEM format, converts it to an rsa.PrivateKey object, and returns it. In case an error occurs, it returns the error.
func EncodeBase64 ¶
EncodeBase64 takes a byte slice and returns the Base64-encoded string.
func EncodeCertificate ¶
EncodeCertificate takes a certificate as a byte slice, encodes it to the PEM format, and returns it as byte slice.
func EncodePrivateKey ¶
func EncodePrivateKey(key *rsa.PrivateKey) []byte
EncodePrivateKey takes a RSA private key object, encodes it to the PEM format, and returns it as a byte slice.
func EncodeSHA1 ¶
EncodeSHA1 takes a byte slice and returns the sha1-hashed string (base64-encoded).
func FindFreePort ¶
FindFreePort finds a free port on the host machine and returns it.
func FuncName ¶
func FuncName(f interface{}) string
FuncName takes a function <f> as input and returns its name as a string. If the function is a method of a struct, the struct will be also prefixed, e.g. 'Botanist.CreateNamespace'.
func GenerateRandomString ¶
GenerateRandomString generates a random string of the specified length <n>. The set of allowed characters is [0-9a-zA-Z], thus no special characters are included in the output.
func GenerateRandomStringFromCharset ¶
GenerateRandomStringFromCharset generates a random string of the specified length <n>. The set of allowed characters can be specified.
func LookupDNS ¶
LookupDNS performs a DNS lookup for the given <domain>. In case of success, it will return the list of records. If the domain is not resolvable, it will return nil.
func MergeMaps ¶
MergeMaps takes two maps <defaults>, <custom> and merges them. If <custom> defines a value with a key already existing in the <defaults> map, the <default> value for that key will be overwritten.
func RenderLocalTemplate ¶
RenderLocalTemplate uses a template <tpl> given as a string and renders it. Thus, the template does not necessarily need to be stored as a file.
func RenderTemplate ¶
RenderTemplate reads the template file in the <templateDir> directory and renders it. It injects a bunch of standard functions which can be used in the template file.
func RenderTemplateWithFuncs ¶
func RenderTemplateWithFuncs(filename string, funcs template.FuncMap, values interface{}) ([]byte, error)
RenderTemplateWithFuncs reads the template file in the <templateDir> directory and renders it. It allows providing a user-defined template.FuncMap <funcs> to the template which will be merged with the standard functions and provided to the template file. The user-defined functions always take precedence in the merge process.
func RenderTemplatesWithFuncs ¶
func RenderTemplatesWithFuncs(filenames []string, funcs template.FuncMap, values interface{}) ([]byte, error)
RenderTemplatesWithFuncs does the same as RenderTemplateWithFuncs except that it allows providing multiple template files instead of only exactly one.
func Retry ¶
Retry tries a condition function <f> until it returns true or the timeout <maxWaitTime> is reached. Retry always waits the 5 seconds before retrying <f> the next time. It ensures that the function <f> is always executed at least once.
func RetryFunc ¶
RetryFunc is a convenience wrapper which returns a condition function that fits the requirements of the Retry function. The function <f> must not require any arguments and only return an error. It will be executed and if it returns an error, the returned-tuple will be (false, err), whereby it will be (true, nil) if the execution of <f> was successful.
func TestEmail ¶
TestEmail validates the provided <email> against a regular expression and returns whether it matches.
func TimeElapsed ¶
TimeElapsed takes a <timestamp> and a <duration> checks whether the elapsed time until now is less than the <duration>. If yes, it returns true, otherwise it returns false.
func ValueExists ¶
ValueExists returns true or false, depending on whether the given string <value> is part of the given []string list <list>.
func WaitUntilDNSNameResolvable ¶
WaitUntilDNSNameResolvable is a helper function which takes a <domain> and waits for a maximum of five minutes that the domain name is resolvable by a DNS. It returns the first record of the resolution, or an error if it was not successful.
Types ¶
This section is empty.