Documentation ¶
Index ¶
- Variables
- func ComputeSHA1Hex(in []byte) string
- func ComputeSHA256Hex(in []byte) string
- func CreateOrUpdateObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, ...) error
- func CreateOrUpdateObjectByRef(ctx context.Context, c client.Client, ...) error
- 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 DecodeRSAPrivateKeyFromPKCS8(bytes []byte) (*rsa.PrivateKey, error)
- func DeleteObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, ...) error
- func DeleteObjectByRef(ctx context.Context, c client.Client, ...) error
- func EncodeBase64(in []byte) string
- func EncodeCertificate(certificate []byte) []byte
- func EncodePrivateKey(key *rsa.PrivateKey) []byte
- func EncodePrivateKeyInPKCS8(key *rsa.PrivateKey) ([]byte, error)
- func EncodeSHA1(in []byte) string
- func FindFreePort() (int, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateRandomStringFromCharset(n int, allowedCharacters string) (string, error)
- func GetObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, ...) (map[string]interface{}, error)
- func GetObjectByRef(ctx context.Context, c client.Client, ...) (map[string]interface{}, error)
- func HashForMap(m map[string]interface{}) string
- func IDForKeyWithOptionalValue(key string, value *string) string
- func IsTrue(value *bool) bool
- func MergeMaps(a, b map[string]interface{}) map[string]interface{}
- func MergeStringMaps(oldMap map[string]string, newMaps ...map[string]string) map[string]string
- 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 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
- type MaintenanceTime
- func (m *MaintenanceTime) Add(hour, minute, second int) *MaintenanceTime
- func (m *MaintenanceTime) Compare(other *MaintenanceTime) int
- func (m *MaintenanceTime) Formatted() string
- func (m *MaintenanceTime) Hour() int
- func (m *MaintenanceTime) Minute() int
- func (m *MaintenanceTime) Second() int
- func (m *MaintenanceTime) String() string
- type MaintenanceTimeWindow
- func (m *MaintenanceTimeWindow) Begin() *MaintenanceTime
- func (m *MaintenanceTimeWindow) Contains(tTime time.Time) bool
- func (m *MaintenanceTimeWindow) Duration() time.Duration
- func (m *MaintenanceTimeWindow) End() *MaintenanceTime
- func (m *MaintenanceTimeWindow) Equal(o *MaintenanceTimeWindow) bool
- func (m *MaintenanceTimeWindow) RandomDurationUntilNext(from time.Time) time.Duration
- func (m *MaintenanceTimeWindow) String() string
- func (m *MaintenanceTimeWindow) WithBegin(begin *MaintenanceTime) *MaintenanceTimeWindow
- func (m *MaintenanceTimeWindow) WithEnd(end *MaintenanceTime) *MaintenanceTimeWindow
Constants ¶
This section is empty.
Variables ¶
var AlwaysTimeWindow = NewMaintenanceTimeWindow(NewMaintenanceTime(0, 0, 0), NewMaintenanceTime(23, 59, 59))
AlwaysTimeWindow is a MaintenanceTimeWindow that contains all durations.
var ( // RandomFunc is a function that computes a random number. RandomFunc = rand.Int63nRange )
Functions ¶
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 CreateOrUpdateObject ¶ added in v1.5.0
func CreateOrUpdateObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, name, namespace string, content map[string]interface{}) error
CreateOrUpdateObject creates or updates the object with the given GVK, name, and namespace using the given client. The object is created or updated with the given content, except for system metadata fields, namespace, and name. This function can be combined with runtime.DefaultUnstructuredConverter.ToUnstructured to create or update an object from runtime.RawExtension.
func CreateOrUpdateObjectByRef ¶ added in v1.5.0
func CreateOrUpdateObjectByRef(ctx context.Context, c client.Client, ref *autoscalingv1.CrossVersionObjectReference, namespace string, content map[string]interface{}) error
CreateOrUpdateObjectByRef creates or updates the object with the given reference and namespace using the given client. The object is created or updated with the given content, except for system metadata fields. This function can be combined with runtime.DefaultUnstructuredConverter.ToUnstructured to create or update an object from runtime.RawExtension.
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 DecodeRSAPrivateKeyFromPKCS8 ¶ added in v1.7.0
func DecodeRSAPrivateKeyFromPKCS8(bytes []byte) (*rsa.PrivateKey, error)
DecodeRSAPrivateKeyFromPKCS8 takes a byte slice, decodes it from the PKCS8 format, tries to convert it to an rsa.PrivateKey object, and returns it. In case an error occurs, it returns the error.
func DeleteObject ¶ added in v1.5.0
func DeleteObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, name, namespace string) error
DeleteObject deletes the object with the given GVK, name, and namespace using the given client.
func DeleteObjectByRef ¶ added in v1.5.0
func DeleteObjectByRef(ctx context.Context, c client.Client, ref *autoscalingv1.CrossVersionObjectReference, namespace string) error
DeleteObjectByRef deletes the object with the given reference and namespace using the given client.
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 EncodePrivateKeyInPKCS8 ¶
func EncodePrivateKeyInPKCS8(key *rsa.PrivateKey) ([]byte, error)
EncodePrivateKeyInPKCS8 takes a RSA private key object, encodes it to the PKCS8 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 GenerateRandomString ¶
GenerateRandomString uses crypto/rand to generate 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. Returns error if there was a problem during the random generation.
func GenerateRandomStringFromCharset ¶
GenerateRandomStringFromCharset generates a cryptographically secure random string of the specified length <n>. The set of allowed characters can be specified. Returns error if there was a problem during the random generation.
func GetObject ¶ added in v1.5.0
func GetObject(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, name, namespace string) (map[string]interface{}, error)
GetObjectByRef returns the object with the given GVK, name, and namespace as a map using the given client. The full content of the object is returned as map[string]interface{}, except for system metadata fields. This function can be combined with runtime.DefaultUnstructuredConverter.FromUnstructured to get the object content as runtime.RawExtension.
func GetObjectByRef ¶ added in v1.5.0
func GetObjectByRef(ctx context.Context, c client.Client, ref *autoscalingv1.CrossVersionObjectReference, namespace string) (map[string]interface{}, error)
GetObjectByRef returns the object with the given reference and namespace using the given client. The full content of the object is returned as map[string]interface{}, except for system metadata fields. This function can be combined with runtime.DefaultUnstructuredConverter.FromUnstructured to get the object content as runtime.RawExtension.
func HashForMap ¶
HashForMap creates a hash value for a map of type map[string]interface{} and returns it.
func IDForKeyWithOptionalValue ¶ added in v1.6.0
IDForKeyWithOptionalValue returns an identifier for the given key + optional value.
func MergeMaps ¶
MergeMaps takes two maps <a>, <b> and merges them. If <b> defines a value with a key already existing in the <a> map, the <a> value for that key will be overwritten.
func MergeStringMaps ¶
MergeStringMaps merges the content of the newMaps with the oldMap. If a key already exists then it gets overwritten by the last value with the same key.
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 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>.
Types ¶
type MaintenanceTime ¶
type MaintenanceTime struct {
// contains filtered or unexported fields
}
MaintenanceTime is a structure holding a maintenance time.
func NewMaintenanceTime ¶
func NewMaintenanceTime(hour, minute, second int) *MaintenanceTime
NewMaintenanceTime returns a maintenance time structure based on the given hour, minute, and second.
func ParseMaintenanceTime ¶
func ParseMaintenanceTime(value string) (*MaintenanceTime, error)
ParseMaintenanceTime parses the given value and returns it as MaintenanceTime object. In case the parsing fails, an error is returned. The time object is converted to UTC zone.
func (*MaintenanceTime) Add ¶
func (m *MaintenanceTime) Add(hour, minute, second int) *MaintenanceTime
Add adds hour, minute and second to <m> and returns a new maintenance time.
func (*MaintenanceTime) Compare ¶
func (m *MaintenanceTime) Compare(other *MaintenanceTime) int
Compare compares the two times <m> and <other>. It returns * i < 0 if <m> is before other * i = 0 if <m> is equal other * i > 0 if <m> is after other
func (*MaintenanceTime) Formatted ¶
func (m *MaintenanceTime) Formatted() string
Formatted formats the maintenance time object to the maintenance time format.
func (*MaintenanceTime) Hour ¶
func (m *MaintenanceTime) Hour() int
Hour returns the hour of the maintenance time.
func (*MaintenanceTime) Minute ¶
func (m *MaintenanceTime) Minute() int
Minute returns the minute of the maintenance time.
func (*MaintenanceTime) Second ¶
func (m *MaintenanceTime) Second() int
Second returns the second of the maintenance time.
func (*MaintenanceTime) String ¶
func (m *MaintenanceTime) String() string
String returns the string representation of the maintenance time.
type MaintenanceTimeWindow ¶
type MaintenanceTimeWindow struct {
// contains filtered or unexported fields
}
MaintenanceTimeWindow contains the beginning and the end of a time window in which maintenance operations can be performed.
func NewMaintenanceTimeWindow ¶
func NewMaintenanceTimeWindow(begin, end *MaintenanceTime) *MaintenanceTimeWindow
NewMaintenanceTimeWindow takes a begin and an end of a time window and returns a pointer to a MaintenanceTimeWindow structure.
func ParseMaintenanceTimeWindow ¶
func ParseMaintenanceTimeWindow(begin, end string) (*MaintenanceTimeWindow, error)
ParseMaintenanceTimeWindow takes a begin and an end of a time window in the maintenance format and returns a pointer to a MaintenanceTimeWindow structure.
func RandomMaintenanceTimeWindow ¶
func RandomMaintenanceTimeWindow() *MaintenanceTimeWindow
RandomMaintenanceTimeWindow computes a random time window and returns both in the format HHMMSS+ZONE.
func (*MaintenanceTimeWindow) Begin ¶
func (m *MaintenanceTimeWindow) Begin() *MaintenanceTime
Begin returns the begin of the time window.
func (*MaintenanceTimeWindow) Contains ¶
func (m *MaintenanceTimeWindow) Contains(tTime time.Time) bool
Contains returns true in case the given time is within the time window.
func (*MaintenanceTimeWindow) Duration ¶
func (m *MaintenanceTimeWindow) Duration() time.Duration
Duration returns the duration of the maintenance time window.
func (*MaintenanceTimeWindow) End ¶
func (m *MaintenanceTimeWindow) End() *MaintenanceTime
End returns the end of the time window.
func (*MaintenanceTimeWindow) Equal ¶ added in v1.2.0
func (m *MaintenanceTimeWindow) Equal(o *MaintenanceTimeWindow) bool
Equal returns true if the time windows are the same.
func (*MaintenanceTimeWindow) RandomDurationUntilNext ¶
func (m *MaintenanceTimeWindow) RandomDurationUntilNext(from time.Time) time.Duration
RandomDurationUntilNext computes the duration until a random time within the time window for the next maintenance execution.
func (*MaintenanceTimeWindow) String ¶
func (m *MaintenanceTimeWindow) String() string
String returns the string representation of the time window.
func (*MaintenanceTimeWindow) WithBegin ¶
func (m *MaintenanceTimeWindow) WithBegin(begin *MaintenanceTime) *MaintenanceTimeWindow
WithBegin returns a new maintenance time window with the given <begin> (ending will be kept).
func (*MaintenanceTimeWindow) WithEnd ¶
func (m *MaintenanceTimeWindow) WithEnd(end *MaintenanceTime) *MaintenanceTimeWindow
WithEnd returns a new maintenance time window with the given <end> (beginning will be kept).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package flow provides utilities to construct a directed acyclic computational graph that is then executed and monitored with maximum parallelism.
|
Package flow provides utilities to construct a directed acyclic computational graph that is then executed and monitored with maximum parallelism. |
validation
|
|