Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteAnnotation(resource runtime.Object, annotation string)
- func DeleteFromSlicePtr(parentSlice interface{}, index int) error
- func DeleteLabel(resource runtime.Object, label string)
- func EqualErrors(a, b Errors) bool
- func GetAnnotation(resource runtime.Object, annotation string) (value string, ok bool)
- func GetLabel(resource runtime.Object, label string) (string, bool)
- func HasAnnotation(resource runtime.Object, annotation string) bool
- func HasLabel(resource runtime.Object, label string) bool
- func InsertIntoMap(parentMap interface{}, key interface{}, value interface{}) error
- func IsEmptyString(value interface{}) bool
- func IsFilePath(path string) bool
- func IsIntKind(k reflect.Kind) bool
- func IsInterfacePtr(v interface{}) bool
- func IsKVPathElement(pe string) bool
- func IsMap(value interface{}) bool
- func IsMapPtr(v interface{}) bool
- func IsNilOrInvalidValue(v reflect.Value) bool
- func IsPtr(value interface{}) bool
- func IsSlice(value interface{}) bool
- func IsSliceInterfacePtr(v interface{}) bool
- func IsSlicePtr(v interface{}) bool
- func IsString(value interface{}) bool
- func IsStruct(value interface{}) bool
- func IsTypeInterface(t reflect.Type) bool
- func IsTypeMap(t reflect.Type) bool
- func IsTypeSlice(t reflect.Type) bool
- func IsTypeSliceOfInterface(t reflect.Type) bool
- func IsTypeSlicePtr(t reflect.Type) bool
- func IsTypeStruct(t reflect.Type) bool
- func IsTypeStructPtr(t reflect.Type) bool
- func IsUintKind(k reflect.Kind) bool
- func IsVPathElement(pe string) bool
- func IsValidPathElement(pe string) bool
- func IsValueInterface(v reflect.Value) bool
- func IsValueMap(v reflect.Value) bool
- func IsValueNil(value interface{}) bool
- func IsValueNilOrDefault(value interface{}) bool
- func IsValuePtr(v reflect.Value) bool
- func IsValueScalar(v reflect.Value) bool
- func IsValueSlice(v reflect.Value) bool
- func IsValueStruct(v reflect.Value) bool
- func IsValueStructPtr(v reflect.Value) bool
- func IsYAMLEqual(a, b string) bool
- func MarshalWithJSONPB(val proto.Message) (string, error)
- func ParseValue(valueStr string) interface{}
- func PathKV(pe string) (k, v string, err error)
- func PathV(pe string) (string, error)
- func PrettyJSON(b []byte) []byte
- func RandomString(n int) string
- func ReadFiles(dirName string, filter FileFilter) (string, error)
- func RemoveBrackets(pe string) (string, bool)
- func SetAnnotation(resource runtime.Object, annotation, value string) error
- func SetLabel(resource runtime.Object, label, value string) error
- func StringBoolMapToSlice(m map[string]bool) []string
- func ToIntValue(val interface{}) (int, bool)
- func ToString(errors []error) string
- func ToYAML(val interface{}) string
- func ToYAMLPathString(path string) string
- func ToYAMLWithJSONPB(val proto.Message) string
- func UnmarshalWithJSONPB(y string, out proto.Message) error
- func UpdateSlicePtr(parentSlice interface{}, index int, value interface{}) error
- func ValuesAreSameType(v1 reflect.Value, v2 reflect.Value) bool
- func YAMLDiff(a, b string) string
- type Errors
- type FileFilter
- type Path
- type Tree
Constants ¶
const ( // PathSeparator is the separator between path elements. PathSeparator = "." // KVSeparator is the separator between the key and value in a key/value path element, KVSeparator = string(kvSeparatorRune) )
Variables ¶
var ( // ValidKeyRegex is a regex for a valid path key element. ValidKeyRegex = regexp.MustCompile("^[a-zA-Z0-9_-]*$") )
Functions ¶
func DeleteAnnotation ¶
DeleteAnnotation is a helper function which deletes the specified annotation from the specified object.
func DeleteFromSlicePtr ¶
DeleteFromSlicePtr deletes an entry at index from the parent, which must be a slice ptr.
func DeleteLabel ¶
DeleteLabel is a helper function which deletes the specified label from the specified object.
func EqualErrors ¶
EqualErrors reports whether a and b are equal, regardless of ordering.
func GetAnnotation ¶
GetAnnotation is a helper function which returns the value of the specified annotation on the specified object. returns ok=false if the annotation was not found on the object.
func GetLabel ¶
GetLabel is a helper function which returns the value of the specified label on the specified object. returns "", false if the label was not found on the object.
func HasAnnotation ¶
HasAnnotation is a helper function returning true if the specified object contains the specified annotation.
func HasLabel ¶
HasLabel is a helper function returning true if the specified object contains the specified label.
func InsertIntoMap ¶
func InsertIntoMap(parentMap interface{}, key interface{}, value interface{}) error
InsertIntoMap inserts value with key into parent which must be a map, map ptr, or interface to map.
func IsEmptyString ¶
func IsEmptyString(value interface{}) bool
IsEmptyString returns true if value is an empty string.
func IsFilePath ¶
IsFilePath reports whether the given URL is a local file path.
func IsInterfacePtr ¶
func IsInterfacePtr(v interface{}) bool
IsInterfacePtr reports whether v is a slice ptr type.
func IsKVPathElement ¶
IsKVPathElement report whether pe is a key/value path element.
func IsNilOrInvalidValue ¶
IsNilOrInvalidValue reports whether v is nil or reflect.Zero.
func IsSliceInterfacePtr ¶
func IsSliceInterfacePtr(v interface{}) bool
IsSliceInterfacePtr reports whether v is a slice ptr type.
func IsSlicePtr ¶
func IsSlicePtr(v interface{}) bool
IsSlicePtr reports whether v is a slice ptr type.
func IsString ¶
func IsString(value interface{}) bool
IsString reports whether value is a string type.
func IsTypeInterface ¶
IsTypeInterface reports whether v is an interface.
func IsTypeSlice ¶
IsTypeSlice reports whether v is a slice type.
func IsTypeSliceOfInterface ¶
IsTypeSliceOfInterface reports whether v is a slice of interface.
func IsTypeSlicePtr ¶
IsTypeSlicePtr reports whether v is a slice ptr type.
func IsTypeStruct ¶
IsTypeStruct reports whether t is a struct type.
func IsTypeStructPtr ¶
IsTypeStructPtr reports whether v is a struct ptr type.
func IsUintKind ¶
IsUintKind reports whether k is an unsigned integer kind of any size.
func IsVPathElement ¶
IsVPathElement report whether pe is a value path element.
func IsValidPathElement ¶
IsValidPathElement reports whether pe is a valid path element.
func IsValueInterface ¶
IsValueInterface reports whether v is an interface type.
func IsValueNil ¶
func IsValueNil(value interface{}) bool
IsValueNil returns true if either value is nil, or has dynamic type {ptr, map, slice} with value nil.
func IsValueNilOrDefault ¶
func IsValueNilOrDefault(value interface{}) bool
IsValueNilOrDefault returns true if either IsValueNil(value) or the default value for the type.
func IsValueScalar ¶
IsValueScalar reports whether v is a scalar type.
func IsValueSlice ¶
IsValueSlice reports whether v is a slice type.
func IsValueStruct ¶
IsValueStruct reports whether v is a struct type.
func IsValueStructPtr ¶
IsValueStructPtr reports whether v is a struct ptr type.
func IsYAMLEqual ¶
IsYAMLEqual reports whether the YAML in strings a and b are equal.
func MarshalWithJSONPB ¶
MarshalWithJSONPB returns a YAML string representation of val (using jsonpb).
func ParseValue ¶
func ParseValue(valueStr string) interface{}
ParseValue parses string into a value
func PathKV ¶
Path KVreturns the key and value string parts of the entire key/value path element. It returns an error if pe is not a key/value path element.
func PathV ¶
PathV returns the value string part of the entire value path element. It returns an error if pe is not a value path element.
func PrettyJSON ¶
PrettyJSON returns a pretty printed version of the JSON string b.
func RandomString ¶
RandomString returns a random string of length n.
func ReadFiles ¶
func ReadFiles(dirName string, filter FileFilter) (string, error)
ReadFiles reads a directory recursively or reads single file and filters the results. It returns a concatenated output of all matching files' content.
func RemoveBrackets ¶
RemoveBrackets removes the [] around pe and returns the resulting string. It returns false if pe is not surrounded by [].
func SetAnnotation ¶
SetAnnotation is a helper function which sets the specified annotation and value on the specified object.
func SetLabel ¶
SetLabel is a helper function which sets the specified label and value on the specified object.
func StringBoolMapToSlice ¶
StringBoolMapToSlice creates and returns a slice of all the map keys with true.
func ToIntValue ¶
ToIntValue returns 0, false if val is not a number type, otherwise it returns the int value of val.
func ToString ¶
ToString returns a string representation of errors. Any nil errors in the slice are skipped.
func ToYAML ¶
func ToYAML(val interface{}) string
ToYAML returns a YAML string representation of val, or the error string if an error occurs.
func ToYAMLPathString ¶
ToYAMLPathString converts a path string such that the first letter of each path element is lower case.
func ToYAMLWithJSONPB ¶
ToYAMLWithJSONPB returns a YAML string representation of val (using jsonpb), or the error string if an error occurs.
func UnmarshalWithJSONPB ¶
UnmarshalWithJSONPB unmarshals y into out using jsonpb (required for many proto defined structs).
func UpdateSlicePtr ¶
UpdateSlicePtr updates an entry at index in the parent, which must be a slice ptr, with the given value.
func ValuesAreSameType ¶
ValuesAreSameType returns true if v1 and v2 has the same reflect.Type, otherwise it returns false.
Types ¶
type Errors ¶
type Errors []error
Errors is a slice of error.
func AppendErr ¶
AppendErr appends err to errors if it is not nil and returns the result. If err is nil, it is not appended.
func AppendErrs ¶
AppendErrs appends newErrs to errors and returns the result. If newErrs is empty, nothing is appended.
func NewErrs ¶
NewErrs returns a slice of error with a single element err. If err is nil, returns nil.
type FileFilter ¶
type Path ¶
type Path []string
Path is a path in slice form.
func PathFromString ¶
PathFromString converts a string path of form a.b.c to a string slice representation.
func ToYAMLPath ¶
ToYAMLPath converts a path string to path such that the first letter of each path element is lower case.