Documentation
¶
Index ¶
- Variables
- func BuildPrometheusLabel(label string) string
- func BuildPrometheusLabels(labels ...string) []string
- func BuildPrometheusMetricName(name string) string
- func BuildRFC1035Label(str string) (string, bool)
- func BuildShellEnvVarName(str string) (string, bool)
- func CastToSliceOfStrings(m map[string]interface{}) []string
- func ConcatSlices[T any](slices [][]T) []T
- func ContextError(ctx context.Context) error
- func CopyMap[TKey comparable, TValue any](src map[TKey]TValue) map[TKey]TValue
- func CopyMapExclude[TKey comparable, TValue any](src map[TKey]TValue, excludeKeys ...TKey) map[TKey]TValue
- func CopyMapFilter[TKey comparable, TValue any](src map[TKey]TValue, includeKeys, excludeKeys []TKey) map[TKey]TValue
- func CopyMapInclude[TKey comparable, TValue any](src map[TKey]TValue, includeKeys ...TKey) map[TKey]TValue
- func CreateStringID(str string, maxHashLen int) string
- func DecBottomed(start, dec, bottom int) int
- func Dump(obj interface{}) string
- func ErrIsNotCanceled(err error) bool
- func ExtToLower(file string) string
- func Fingerprint(obj interface{}) string
- func Fprintf(w io.Writer, format string, a ...interface{})
- func HasEnvVar(haystack []core.EnvVar, needle core.EnvVar) bool
- func HashIntoInt(b []byte) int
- func HashIntoIntTopped(b []byte, top int) int
- func HashIntoString(b []byte) string
- func Iline(w io.Writer, indent int, format string, a ...interface{})
- func InArray(needle string, haystack []string) bool
- func InArrayWithRegexp(needle string, haystack []string) bool
- func IncTopped(start, inc, top int) int
- func IncludeNonEmpty[TKey comparable, TValue any](dst map[TKey]TValue, key TKey, value TValue)
- func IntersectStringArrays(a []string, b []string) (res []string)
- func IsAnnotationToBeSkipped(annotation string) bool
- func IsContextDone(ctx context.Context) bool
- func IsDirOk(path string) bool
- func IsShellEnvVarName(value string) bool
- func IsValidDNS1035Label(value string) bool
- func IsValidPrometheusLabel(value string) bool
- func IsValidPrometheusLabelValue(value string) bool
- func IsValidPrometheusMetricName(value string) bool
- func ListSkippedAnnotations() []string
- func Map2String[TKey constraints.Ordered, TValue any](name string, m map[TKey]TValue) string
- func MapDeleteKeys[TKey comparable, TValue any](m map[TKey]TValue, keys ...TKey) map[TKey]TValue
- func MapGetKeys[TKey comparable, TValue any](m map[TKey]TValue) (keys []TKey)
- func MapGetSortedKeys[TKey constraints.Ordered, TValue any](m map[TKey]TValue) (keys []TKey)
- func MapGetSortedKeysAndValues[TKey constraints.Ordered, TValue any](m map[TKey]TValue) (keys []TKey, values []TValue)
- func MapHasKeys[TKey comparable, TValue any](m map[TKey]TValue, keys ...TKey) bool
- func MapMigrate[TKey constraints.Ordered, TValue any](cur, new, old map[TKey]TValue) map[TKey]TValue
- func MapsAreTheSame[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue) bool
- func MapsHaveKeyValuePairsIntersection[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue) bool
- func MapsHaveKeysIntersection[TKey comparable, TValue any](m1, m2 map[TKey]TValue) bool
- func MapsHaveSameKeyValuePairs[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue, keys ...TKey) (same bool)
- func MapsIntersectKeys[TKey comparable, TValue any](m1, m2 map[TKey]TValue) (keysIntersection []TKey)
- func MergeEnvVars(to []core.EnvVar, from ...core.EnvVar) []core.EnvVar
- func MergeStringArrays(dst []string, src []string) []string
- func MergeStringMapsOverwrite[TKey comparable, TValue any](dst, src map[TKey]TValue, keys ...TKey) map[TKey]TValue
- func MergeStringMapsPreserve[TKey comparable, TValue any](dst, src map[TKey]TValue, keys ...TKey) map[TKey]TValue
- func MessageDiffItemString(bannerForDiff, bannerForNoDiff, defaultPath string, ...) (str string)
- func MessageDiffString(diff *messagediff.Diff, equal bool) string
- func NamespaceName(meta iNamespaceName) (string, string)
- func NamespaceNameString(meta iNamespaceName) string
- func NamespacedName(obj iNamespaceName) types.NamespacedName
- func NonEmpty(slice []string) (nonEmpty []string)
- func Prefix(slice []string, prefix string) (res []string)
- func PreparePath(path *string, basePath, defaultRelativePath string)
- func RandString(length int) string
- func RandStringRange(minLength, maxLength int) string
- func ReadFilesIntoMap(path string, isOurFile func(string) bool) map[string]string
- func ReasonableDuration(durations ...time.Duration) time.Duration
- func RelativeToBasePath(basePath, relativePath string) string
- func RemoveFromArray(needle string, haystack []string) []string
- func Slice2String(name string, slice []string) string
- func SliceDistinct[T comparable](slice []T) (distinct []T)
- func SlicesIntersect[T comparable](a, b []T) (intersection []T)
- func StringHead(str string, maxHeadLen int) string
- func StringSliceContains(haystack []string, needle string) bool
- func SubtractStringMaps[TKey comparable, TValue any](base, delta map[TKey]TValue) map[TKey]TValue
- func Unique(slice []string) (unique []string)
- func Unzip(slice [][]string) ([]string, []string)
- func WaitContextDoneOrTimeout(ctx context.Context, timeout time.Duration) bool
- func WaitContextDoneUntil(ctx context.Context, t time.Time) bool
- type MapReplacer
- type Replacer
- func (e *Replacer) Line(line string) string
- func (e *Replacer) LineEx(line string) (string, bool)
- func (e *Replacer) Map(_map map[string]string) map[string]string
- func (e *Replacer) MapEx(_map map[string]string) (map[string]string, bool)
- func (e *Replacer) Slice(s []string) []string
- func (e *Replacer) SliceEx(s []string) ([]string, bool)
- func (e *Replacer) String() string
- type Slice
- type SliceReplacer
Constants ¶
This section is empty.
Variables ¶
var AnnotationsToBeSkipped = []string{
"kubectl.kubernetes.io/last-applied-configuration",
}
AnnotationsToBeSkipped kubectl service annotation that we'd like to skip
Functions ¶
func BuildPrometheusLabel ¶
func BuildPrometheusLabels ¶
func BuildRFC1035Label ¶
func BuildShellEnvVarName ¶
func CastToSliceOfStrings ¶
CastToSliceOfStrings makes slice of strings from map
func ConcatSlices ¶
func ConcatSlices[T any](slices [][]T) []T
func ContextError ¶
ContextError is a one-word syntactic sugar to check what error is reported by the context.
func CopyMap ¶
func CopyMap[TKey comparable, TValue any](src map[TKey]TValue) map[TKey]TValue
CopyMap creates a copy of the given map by copying over key by key. It doesn't perform a deep-copy.
func CopyMapExclude ¶
func CopyMapExclude[TKey comparable, TValue any](src map[TKey]TValue, excludeKeys ...TKey) map[TKey]TValue
CopyMapExclude creates a copy of the given map but will exclude the given set of keys.
func CopyMapFilter ¶
func CopyMapFilter[TKey comparable, TValue any](src map[TKey]TValue, includeKeys, excludeKeys []TKey) map[TKey]TValue
CopyMapFilter copies maps with keys filtering. Keys specified in 'include' are included, keys specified in 'exclude' are excluded. However, 'include' keys are applied only in case 'include' list is not empty.
func CopyMapInclude ¶
func CopyMapInclude[TKey comparable, TValue any](src map[TKey]TValue, includeKeys ...TKey) map[TKey]TValue
CopyMapInclude creates a copy of the given map but will include the given set of keys only. However, keys are applied only in case list is not empty. In case of an empty list, no filtering is performed and all keys are copied.
func CreateStringID ¶
CreateStringID creates HEX hash ID out of a string. In case maxHashLen == 0 the whole hash is returned
func DecBottomed ¶
func ErrIsNotCanceled ¶
ErrIsNotCanceled checks whether specified error is either not an error is is not a context.Canceled
func ExtToLower ¶
ExtToLower fetches and lower-cases file extension. With dot, as '.xml'
func Fingerprint ¶
func Fingerprint(obj interface{}) string
Fingerprint creates object's fingerprint
func HashIntoInt ¶
HashIntoInt hashes bytes and returns int version of the hash
func HashIntoIntTopped ¶
HashIntoIntTopped hashes bytes and return int version of the ash topped with top
func HashIntoString ¶
HashIntoString hashes bytes and returns string version of the hash
func InArrayWithRegexp ¶
InArrayWithRegexp checks whether the needle can be matched by haystack
func IncludeNonEmpty ¶
func IncludeNonEmpty[TKey comparable, TValue any](dst map[TKey]TValue, key TKey, value TValue)
IncludeNonEmpty inserts (and overwrites) data into map object using specified key, if not empty value provided
func IntersectStringArrays ¶
IntersectStringArrays intersects arrays `a` and `b`
func IsAnnotationToBeSkipped ¶
IsAnnotationToBeSkipped checks whether an annotation should be skipped
func IsContextDone ¶
IsContextDone is a non-blocking one-word syntactic sugar to check whether context is done. Convenient to be used as
if IsContextDone(ctx) { ... do something ... }
func IsShellEnvVarName ¶
IsShellEnvVarName tests for a string that conforms to the definition of a shell ENV VAR name
func IsValidDNS1035Label ¶
IsValidDNS1035Label tests for a string that conforms to the definition of a label in DNS (RFC 1035).
func IsValidPrometheusLabel ¶
IsValidPrometheusLabel tests for a string that conforms to the definition of a label in Prometheus
func IsValidPrometheusMetricName ¶
IsValidPrometheusMetricName tests for a string that conforms to the definition of a metric in Prometheus
func ListSkippedAnnotations ¶
func ListSkippedAnnotations() []string
ListSkippedAnnotations provides list of annotations that should be skipped
func Map2String ¶
func Map2String[TKey constraints.Ordered, TValue any](name string, m map[TKey]TValue) string
Map2String returns named map as a string
func MapDeleteKeys ¶
func MapDeleteKeys[TKey comparable, TValue any](m map[TKey]TValue, keys ...TKey) map[TKey]TValue
MapDeleteKeys deletes multiple keys from the map
func MapGetKeys ¶
func MapGetKeys[TKey comparable, TValue any](m map[TKey]TValue) (keys []TKey)
func MapGetSortedKeys ¶
func MapGetSortedKeys[TKey constraints.Ordered, TValue any](m map[TKey]TValue) (keys []TKey)
func MapGetSortedKeysAndValues ¶
func MapGetSortedKeysAndValues[TKey constraints.Ordered, TValue any](m map[TKey]TValue) (keys []TKey, values []TValue)
func MapHasKeys ¶
func MapHasKeys[TKey comparable, TValue any](m map[TKey]TValue, keys ...TKey) bool
MapHasKeys checks whether map has all keys from specified list
func MapMigrate ¶
func MapMigrate[TKey constraints.Ordered, TValue any](cur, new, old map[TKey]TValue) map[TKey]TValue
func MapsAreTheSame ¶
func MapsAreTheSame[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue) bool
func MapsHaveKeyValuePairsIntersection ¶
func MapsHaveKeyValuePairsIntersection[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue) bool
func MapsHaveKeysIntersection ¶
func MapsHaveKeysIntersection[TKey comparable, TValue any](m1, m2 map[TKey]TValue) bool
func MapsHaveSameKeyValuePairs ¶
func MapsHaveSameKeyValuePairs[TKey comparable, TValue comparable](m1, m2 map[TKey]TValue, keys ...TKey) (same bool)
func MapsIntersectKeys ¶
func MapsIntersectKeys[TKey comparable, TValue any](m1, m2 map[TKey]TValue) (keysIntersection []TKey)
func MergeEnvVars ¶
MergeEnvVars appends to `to` elements from `from` which are not found in `to`
func MergeStringArrays ¶
MergeStringArrays appends into dst items from src that are not present in src. src items are being deduplicated
func MergeStringMapsOverwrite ¶
func MergeStringMapsOverwrite[TKey comparable, TValue any](dst, src map[TKey]TValue, keys ...TKey) map[TKey]TValue
MergeStringMapsOverwrite inserts (and overwrites) data into dst map object from src
func MergeStringMapsPreserve ¶
func MergeStringMapsPreserve[TKey comparable, TValue any](dst, src map[TKey]TValue, keys ...TKey) map[TKey]TValue
MergeStringMapsPreserve inserts (and preserved existing) data into dst map object from src
func MessageDiffItemString ¶
func MessageDiffItemString(bannerForDiff, bannerForNoDiff, defaultPath string, items map[*messagediff.Path]interface{}) (str string)
MessageDiffItemString stringifies one map[*messagediff.Path]interface{} item
func MessageDiffString ¶
MessageDiffString stringifies message diff
func NamespaceName ¶
NamespaceName returns namespace and anme from the meta
func NamespaceNameString ¶
func NamespaceNameString(meta iNamespaceName) string
NamespaceNameString returns namespace and name as one string
func NamespacedName ¶
func NamespacedName(obj iNamespaceName) types.NamespacedName
NamespacedName returns NamespacedName from obj
func PreparePath ¶
PreparePath - prepares path absolute/relative with default relative value
func RandString ¶
RandString generates random string of specified length
func RandStringRange ¶
RandStringRange specifies random string with length in specified range
func ReadFilesIntoMap ¶
ReadFilesIntoMap reads config files from specified path into "file name->file content" map path - folder where to look for files isOurFile - accepts path to file return bool whether this file should be read
func ReasonableDuration ¶
ReasonableDuration finds first duration > 0 or returns 0 in case no durations provided
func RelativeToBasePath ¶
RelativeToBasePath returns absolute path relative to base
func RemoveFromArray ¶
RemoveFromArray removes the needle from the haystack
func Slice2String ¶
Slice2String returns named slice as a string
func SliceDistinct ¶
func SliceDistinct[T comparable](slice []T) (distinct []T)
SliceDistinct returns distinct slice
func SlicesIntersect ¶
func SlicesIntersect[T comparable](a, b []T) (intersection []T)
func StringHead ¶
StringHead returns beginning of the string of requested length
func StringSliceContains ¶
StringSliceContains implements contain method for string slice
func SubtractStringMaps ¶
func SubtractStringMaps[TKey comparable, TValue any](base, delta map[TKey]TValue) map[TKey]TValue
SubtractStringMaps subtracts "delta" from "base" by keys
func WaitContextDoneOrTimeout ¶
WaitContextDoneOrTimeout waits either for ctx to be done or specified timeout returns true in case ctx is Done or false in case timeout reached
Types ¶
type MapReplacer ¶
MapReplacer replaces a list of strings with replacements on a map.
func NewMapReplacer ¶
func NewMapReplacer(r *strings.Replacer) *MapReplacer
NewMapReplacer creates new MapReplacer
type Replacer ¶
type Replacer struct {
// contains filtered or unexported fields
}
func NewReplacer ¶
NewReplacer
func NewReplacerFrom ¶
type SliceReplacer ¶
SliceReplacer replaces a list of strings with replacements on a slice.
func NewSliceReplacer ¶
func NewSliceReplacer(r *strings.Replacer) *SliceReplacer
NewSliceReplacer creates new SliceReplacer
func (*SliceReplacer) Replace ¶
func (r *SliceReplacer) Replace(m []string) []string
Replace returns a copy of m with all replacements performed.