Documentation ¶
Index ¶
- Constants
- Variables
- func CastStringBoolTo01(str string, defaultValue bool) string
- func CastStringBoolToStringTrueFalse(str string, defaultValue bool) string
- func CastToSliceOfStrings(m map[string]interface{}) []string
- 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 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 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 IncludeNonEmpty(dst map[string]string, key, src string)
- func IsAnnotationToBeSkipped(annotation string) bool
- func IsContextDone(ctx context.Context) bool
- func IsDirOk(path string) bool
- func IsStringBool(str string) bool
- func IsStringBoolFalse(str string) bool
- func IsStringBoolTrue(str 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 MapHasKeys(m map[string]string, keys ...string) bool
- 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(banner string, items map[*messagediff.Path]interface{}) string
- func MessageDiffString(diff *messagediff.Diff, equal bool) string
- func NamespaceName(meta v1.ObjectMeta) (string, string)
- func NamespaceNameString(meta v1.ObjectMeta) string
- func PreparePath(path *string, basePath, defaultRelativePath 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 SubtractStringMaps(base, delta map[string]string) map[string]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 ¶
const ( StringBool0 = "0" StringBool1 = "1" StringBoolFalseFirstCapital = "False" StringBoolFalseLowercase = "false" StringBoolTrueFirstCapital = "True" StringBoolTrueLowercase = "true" StringBoolNoFirstCapital = "No" StringBoolNoLowercase = "no" StringBoolYesFirstCapital = "Yes" StringBoolYesLowercase = "yes" StringBoolOffFirstCapital = "Off" StringBoolOffLowercase = "off" StringBoolOnFirstCapital = "On" StringBoolOnLowercase = "on" StringBoolDisableFirstCapital = "Disable" StringBoolDisableLowercase = "disable" StringBoolEnableFirstCapital = "Enable" StringBoolEnableLowercase = "enable" StringBoolDisabledFirstCapital = "Disabled" StringBoolDisabledLowercase = "disabled" StringBoolEnabledFirstCapital = "Enabled" StringBoolEnabledLowercase = "enabled" )
Set of string boolean constants
Variables ¶
var AnnotationsTobeSkipped = []string{
"kubectl.kubernetes.io/last-applied-configuration",
}
AnnotationsTobeSkipped kubectl service annotation that we'd like to skip
Functions ¶
func CastStringBoolTo01 ¶
CastStringBoolTo01 casts string-bool into string "0/1"
func CastStringBoolToStringTrueFalse ¶
CastStringBoolToStringTrueFalse casts string-bool into string "true/false"
func CastToSliceOfStrings ¶
CastToSliceOfStrings makes slice of strings from map
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 string. In case maxHashLen == 0 the whole hash is returned
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 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 IsStringBool ¶
IsStringBool checks whether str is a string as bool value
func IsStringBoolFalse ¶
IsStringBoolFalse checks whether str is a string as bool "false" value
func IsStringBoolTrue ¶
IsStringBoolTrue checks whether str is a string as bool "true" value
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 MapHasKeys ¶
MapHasKeys checks whether map has all keys from specified list
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 ¶
MessageDiffItemString stringifies one map[*messagediff.Path]interface{} item
func MessageDiffString ¶
MessageDiffString stringifies message diff
func NamespaceName ¶
func NamespaceName(meta v1.ObjectMeta) (string, string)
NamespaceName returns namespace and anme from the meta
func NamespaceNameString ¶
func NamespaceNameString(meta v1.ObjectMeta) string
NamespaceNameString returns namespace and name as one string
func PreparePath ¶
PreparePath - prepares path absolute/relative with default relative value
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 removed 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 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