import "istio.io/istio/operator/pkg/util"
common.go errs.go k8s.go label.go merge_iop.go path.go reflect.go util.go yaml.go
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) // InsertIndex is the index that means "insert" when setting values InsertIndex = -1 // EscapedPathSeparator is what to use when the path shouldn't separate EscapedPathSeparator = "\\" + PathSeparator )
var ( // ValidKeyRegex is a regex for a valid path key element. ValidKeyRegex = regexp.MustCompile("^[a-zA-Z0-9_-]*$") )
ConsolidateLog is a helper function to dedup the log message.
DeleteFromMap deletes an entry with the given key parent, which must be a map.
DeleteFromSlicePtr deletes an entry at index from the parent, which must be a slice ptr.
EqualErrors reports whether a and b are equal, regardless of ordering.
func FindFiles(path string, filter FileFilter) ([]string, error)
FindFiles reads files from path, and returns the file names that match the filter.
GKString differs from default representation of GroupKind
InsertIntoMap inserts value with key into parent which must be a map, map ptr, or interface to map.
IsEmptyString returns true if value is an empty string.
IsFilePath reports whether the given URL is a local file path.
IsHTTPURL checks whether the given URL is a HTTP URL.
IsIntKind reports whether k is an integer kind of any size.
IsKVPathElement report whether pe is a key/value path element.
IsMap reports whether value is a map type.
IsMapPtr reports whether v is a map ptr type.
IsNPathElement report whether pe is an index path element.
IsNilOrInvalidValue reports whether v is nil or reflect.Zero.
IsPtr reports whether value is a ptr type.
IsSlice reports whether value is a slice type.
IsSliceInterfacePtr reports whether v is a slice ptr type.
IsSlicePtr reports whether v is a slice ptr type.
IsString reports whether value is a string type.
IsStruct reports whether value is a struct type
IsTypeInterface reports whether v is an interface.
IsTypeMap reports whether v is a map type.
IsTypeSliceOfInterface reports whether v is a slice of interface.
IsTypeSlicePtr reports whether v is a slice ptr type.
IsTypeStructPtr reports whether v is a struct ptr type.
IsUintKind reports whether k is an unsigned integer kind of any size.
IsVPathElement report whether pe is a value path element.
IsValidPathElement reports whether pe is a valid path element.
IsValueInterface reports whether v is an interface type.
IsValueMap reports whether v is a map type.
IsValueNil returns true if either value is nil, or has dynamic type {ptr, map, slice} with value nil.
IsValueNilOrDefault returns true if either IsValueNil(value) or the default value for the type.
IsValuePtr reports whether v is a ptr type.
IsValueScalar reports whether v is a scalar type.
IsValueSlice reports whether v is a slice type.
IsValueStruct reports whether v is a struct type.
IsValueStructPtr reports whether v is a struct ptr type.
IsYAMLEmpty reports whether the YAML string y is logically empty.
IsYAMLEqual reports whether the YAML in strings a and b are equal.
MarshalWithJSONPB returns a YAML string representation of val (using jsonpb).
OverlayIOP overlays over base using JSON strategic merge.
func OverlayTrees(base map[string]interface{}, overlays ...map[string]interface{}) (map[string]interface{}, error)
OverlayTrees performs a sequential JSON strategic of overlays over base.
OverlayYAML patches the overlay tree over the base tree and returns the result. All trees are expressed as YAML strings.
ParseValue parses string into a value
PathKV returns 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.
PathN returns the index part of the entire value path element. It returns an error if pe is not an index path element.
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 ReadFilesWithFilter(path string, filter FileFilter) (string, error)
ReadFilesWithFilter reads files from path, for a directory it recursively reads files and filters the results for single file it directly reads the file. It returns a concatenated output of all matching files' content.
RemoveBrackets removes the [] around pe and returns the resulting string. It returns false if pe is not surrounded by [].
RenderTemplate is a helper method to render a template with the given values.
SetLabel is a helper function which sets the specified label and value on the specified object.
StringBoolMapToSlice creates and returns a slice of all the map keys with true.
ToIntValue returns 0, false if val is not a number type, otherwise it returns the int value of val.
ToString returns a string representation of errors, with elements separated by separator string. Any nil errors in the slice are skipped.
ToYAML returns a YAML string representation of val, or the error string if an error occurs.
ToYAMLPathString converts a path string such that the first letter of each path element is lower case.
ToYAMLWithJSONPB returns a YAML string representation of val (using jsonpb), or the error string if an error occurs.
UnmarshalWithJSONPB unmarshals y into out using gogo jsonpb (required for many proto defined structs).
UpdateSlicePtr updates an entry at index in the parent, which must be a slice ptr, with the given value.
ValuesAreSameType returns true if v1 and v2 has the same reflect.Type, otherwise it returns false.
Errors is a slice of error.
AppendErr appends err to errors if it is not nil and returns the result. If err is nil, it is not appended.
AppendErrs appends newErrs to errors and returns the result. If newErrs is empty, nothing is appended.
NewErrs returns a slice of error with a single element err. If err is nil, returns nil.
Dedup removes any duplicated errors.
Error implements the error#Error method.
String implements the stringer#String method.
ToError returns an error from Errors.
DetectSupportedJWTPolicy queries the api-server to detect whether it has TokenRequest support
Path is a path in slice form.
PathFromString converts a string path of form a.b.c to a string slice representation.
ToYAMLPath converts a path string to path such that the first letter of each path element is lower case.
String converts a string slice path representation of form ["a", "b", "c"] to a string representation like "a.b.c".
Path | Synopsis |
---|---|
clog | |
httpserver | |
progress | |
tgz |
Package util imports 31 packages (graph) and is imported by 22 packages. Updated 2020-12-21. Refresh now. Tools for package owners.