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(src map[string]string) map[string]string
- func CopyMapExclude(src map[string]string, exceptKeys ...string) map[string]string
- func CopyMapFilter(src map[string]string, include, exclude []string) map[string]string
- func CopyMapInclude(src map[string]string, keys ...string) map[string]string
- 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(dst map[string]string, key, src string)
- 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(name string, m map[string]string) string
- func MapDeleteKeys(base map[string]string, keys ...string) map[string]string
- func MapGetSortedKeys(m map[string]string) (keys []string)
- func MapGetSortedKeysAndValues(m map[string]string) (keys []string, values []string)
- func MapHasKeys(m map[string]string, keys ...string) bool
- func MapMigrate(cur, new, old map[string]string) map[string]string
- func MergeEnvVars(to []core.EnvVar, from ...core.EnvVar) []core.EnvVar
- func MergeStringArrays(dst []string, src []string) []string
- func MergeStringMapsOverwrite(dst, src map[string]string, keys ...string) map[string]string
- func MergeStringMapsPreserve(dst, src map[string]string, keys ...string) map[string]string
- func MessageDiffItemString(bannerForDiff, bannerForNoDiff, defaultPath string, ...) (str string)
- func MessageDiffString(diff *messagediff.Diff, equal bool) string
- func NamespaceName(meta meta.Object) (string, string)
- func NamespaceNameString(meta meta.Object) string
- func NamespacedName(obj meta.Object) 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 StringHead(str string, maxHeadLen int) string
- func StringSliceContains(haystack []string, needle string) bool
- func SubtractStringMaps(base, delta map[string]string) map[string]string
- 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
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 ¶
CopyMap creates a copy of the given map by copying over key by key. It doesn't perform a deep-copy.
func CopyMapExclude ¶
CopyMapExclude creates a copy of the given map but will exclude the given set of keys.
func CopyMapFilter ¶
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 ¶
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 ¶
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 ¶
Map2String returns named map[string]string mas as a string
func MapDeleteKeys ¶
MapDeleteKeys deletes multiple keys from the map
func MapGetSortedKeys ¶
func MapHasKeys ¶
MapHasKeys checks whether map has all keys from specified list
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 ¶
MergeStringMapsOverwrite inserts (and overwrites) data into dst map object from src
func MergeStringMapsPreserve ¶
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 ¶
NamespaceNameString returns namespace and name as one string
func NamespacedName ¶
func NamespacedName(obj meta.Object) 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 StringHead ¶
StringHead returns beginning of the string of requested length
func StringSliceContains ¶
StringSliceContains implements contain method for string slice
func SubtractStringMaps ¶
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