istio: Index | Files | Directories

package util

import ""


Package Files

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_-]*$")

func ConsolidateLog Uses

func ConsolidateLog(logMessage string) string

ConsolidateLog is a helper function to dedup the log message.

func DeleteFromMap Uses

func DeleteFromMap(parentMap interface{}, key interface{}) error

DeleteFromMap deletes an entry with the given key parent, which must be a map.

func DeleteFromSlicePtr Uses

func DeleteFromSlicePtr(parentSlice interface{}, index int) error

DeleteFromSlicePtr deletes an entry at index from the parent, which must be a slice ptr.

func EqualErrors Uses

func EqualErrors(a, b Errors) bool

EqualErrors reports whether a and b are equal, regardless of ordering.

func FindFiles Uses

func FindFiles(path string, filter FileFilter) ([]string, error)

FindFiles reads files from path, and returns the file names that match the filter.

func GKString Uses

func GKString(gvk schema.GroupKind) string

GKString differs from default representation of GroupKind

func InsertIntoMap Uses

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 Uses

func IsEmptyString(value interface{}) bool

IsEmptyString returns true if value is an empty string.

func IsFilePath Uses

func IsFilePath(path string) bool

IsFilePath reports whether the given URL is a local file path.

func IsHTTPURL Uses

func IsHTTPURL(path string) (bool, error)

IsHTTPURL checks whether the given URL is a HTTP URL.

func IsIntKind Uses

func IsIntKind(k reflect.Kind) bool

IsIntKind reports whether k is an integer kind of any size.

func IsKVPathElement Uses

func IsKVPathElement(pe string) bool

IsKVPathElement report whether pe is a key/value path element.

func IsMap Uses

func IsMap(value interface{}) bool

IsMap reports whether value is a map type.

func IsMapPtr Uses

func IsMapPtr(v interface{}) bool

IsMapPtr reports whether v is a map ptr type.

func IsNPathElement Uses

func IsNPathElement(pe string) bool

IsNPathElement report whether pe is an index path element.

func IsNilOrInvalidValue Uses

func IsNilOrInvalidValue(v reflect.Value) bool

IsNilOrInvalidValue reports whether v is nil or reflect.Zero.

func IsPtr Uses

func IsPtr(value interface{}) bool

IsPtr reports whether value is a ptr type.

func IsSlice Uses

func IsSlice(value interface{}) bool

IsSlice reports whether value is a slice type.

func IsSliceInterfacePtr Uses

func IsSliceInterfacePtr(v interface{}) bool

IsSliceInterfacePtr reports whether v is a slice ptr type.

func IsSlicePtr Uses

func IsSlicePtr(v interface{}) bool

IsSlicePtr reports whether v is a slice ptr type.

func IsString Uses

func IsString(value interface{}) bool

IsString reports whether value is a string type.

func IsStruct Uses

func IsStruct(value interface{}) bool

IsStruct reports whether value is a struct type

func IsTypeInterface Uses

func IsTypeInterface(t reflect.Type) bool

IsTypeInterface reports whether v is an interface.

func IsTypeMap Uses

func IsTypeMap(t reflect.Type) bool

IsTypeMap reports whether v is a map type.

func IsTypeSliceOfInterface Uses

func IsTypeSliceOfInterface(t reflect.Type) bool

IsTypeSliceOfInterface reports whether v is a slice of interface.

func IsTypeSlicePtr Uses

func IsTypeSlicePtr(t reflect.Type) bool

IsTypeSlicePtr reports whether v is a slice ptr type.

func IsTypeStructPtr Uses

func IsTypeStructPtr(t reflect.Type) bool

IsTypeStructPtr reports whether v is a struct ptr type.

func IsUintKind Uses

func IsUintKind(k reflect.Kind) bool

IsUintKind reports whether k is an unsigned integer kind of any size.

func IsVPathElement Uses

func IsVPathElement(pe string) bool

IsVPathElement report whether pe is a value path element.

func IsValidPathElement Uses

func IsValidPathElement(pe string) bool

IsValidPathElement reports whether pe is a valid path element.

func IsValueInterface Uses

func IsValueInterface(v reflect.Value) bool

IsValueInterface reports whether v is an interface type.

func IsValueMap Uses

func IsValueMap(v reflect.Value) bool

IsValueMap reports whether v is a map type.

func IsValueNil Uses

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 Uses

func IsValueNilOrDefault(value interface{}) bool

IsValueNilOrDefault returns true if either IsValueNil(value) or the default value for the type.

func IsValuePtr Uses

func IsValuePtr(v reflect.Value) bool

IsValuePtr reports whether v is a ptr type.

func IsValueScalar Uses

func IsValueScalar(v reflect.Value) bool

IsValueScalar reports whether v is a scalar type.

func IsValueSlice Uses

func IsValueSlice(v reflect.Value) bool

IsValueSlice reports whether v is a slice type.

func IsValueStruct Uses

func IsValueStruct(v reflect.Value) bool

IsValueStruct reports whether v is a struct type.

func IsValueStructPtr Uses

func IsValueStructPtr(v reflect.Value) bool

IsValueStructPtr reports whether v is a struct ptr type.

func IsYAMLEmpty Uses

func IsYAMLEmpty(y string) bool

IsYAMLEmpty reports whether the YAML string y is logically empty.

func IsYAMLEqual Uses

func IsYAMLEqual(a, b string) bool

IsYAMLEqual reports whether the YAML in strings a and b are equal.

func MarshalWithJSONPB Uses

func MarshalWithJSONPB(val proto.Message) (string, error)

MarshalWithJSONPB returns a YAML string representation of val (using jsonpb).

func OverlayIOP Uses

func OverlayIOP(base, overlay string) (string, error)

OverlayIOP overlays over base using JSON strategic merge.

func OverlayTrees Uses

func OverlayTrees(base map[string]interface{}, overlays[string]interface{}) (map[string]interface{}, error)

OverlayTrees performs a sequential JSON strategic of overlays over base.

func OverlayYAML Uses

func OverlayYAML(base, overlay string) (string, error)

OverlayYAML patches the overlay tree over the base tree and returns the result. All trees are expressed as YAML strings.

func ParseValue Uses

func ParseValue(valueStr string) interface{}

ParseValue parses string into a value

func PathKV Uses

func PathKV(pe string) (k, v string, err error)

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.

func PathN Uses

func PathN(pe string) (int, error)

PathN returns the index part of the entire value path element. It returns an error if pe is not an index path element.

func PathV Uses

func PathV(pe string) (string, error)

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 Uses

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.

func RemoveBrackets Uses

func RemoveBrackets(pe string) (string, bool)

RemoveBrackets removes the [] around pe and returns the resulting string. It returns false if pe is not surrounded by [].

func RenderTemplate Uses

func RenderTemplate(tmpl string, ts interface{}) (string, error)

RenderTemplate is a helper method to render a template with the given values.

func SetLabel Uses

func SetLabel(resource runtime.Object, label, value string) error

SetLabel is a helper function which sets the specified label and value on the specified object.

func StringBoolMapToSlice Uses

func StringBoolMapToSlice(m map[string]bool) []string

StringBoolMapToSlice creates and returns a slice of all the map keys with true.

func ToIntValue Uses

func ToIntValue(val interface{}) (int, bool)

ToIntValue returns 0, false if val is not a number type, otherwise it returns the int value of val.

func ToString Uses

func ToString(errors []error, separator string) string

ToString returns a string representation of errors, with elements separated by separator string. Any nil errors in the slice are skipped.

func ToYAML Uses

func ToYAML(val interface{}) string

ToYAML returns a YAML string representation of val, or the error string if an error occurs.

func ToYAMLPathString Uses

func ToYAMLPathString(path string) string

ToYAMLPathString converts a path string such that the first letter of each path element is lower case.

func ToYAMLWithJSONPB Uses

func ToYAMLWithJSONPB(val proto.Message) string

ToYAMLWithJSONPB returns a YAML string representation of val (using jsonpb), or the error string if an error occurs.

func UnmarshalWithJSONPB Uses

func UnmarshalWithJSONPB(y string, out proto.Message, allowUnknownField bool) error

UnmarshalWithJSONPB unmarshals y into out using gogo jsonpb (required for many proto defined structs).

func UpdateSlicePtr Uses

func UpdateSlicePtr(parentSlice interface{}, index int, value interface{}) error

UpdateSlicePtr updates an entry at index in the parent, which must be a slice ptr, with the given value.

func ValuesAreSameType Uses

func ValuesAreSameType(v1 reflect.Value, v2 reflect.Value) bool

ValuesAreSameType returns true if v1 and v2 has the same reflect.Type, otherwise it returns false.

func YAMLDiff Uses

func YAMLDiff(a, b string) string

type Errors Uses

type Errors []error

Errors is a slice of error.

func AppendErr Uses

func AppendErr(errors []error, err error) Errors

AppendErr appends err to errors if it is not nil and returns the result. If err is nil, it is not appended.

func AppendErrs Uses

func AppendErrs(errors []error, newErrs []error) Errors

AppendErrs appends newErrs to errors and returns the result. If newErrs is empty, nothing is appended.

func NewErrs Uses

func NewErrs(err error) Errors

NewErrs returns a slice of error with a single element err. If err is nil, returns nil.

func (Errors) Dedup Uses

func (e Errors) Dedup() Errors

Dedup removes any duplicated errors.

func (Errors) Error Uses

func (e Errors) Error() string

Error implements the error#Error method.

func (Errors) String Uses

func (e Errors) String() string

String implements the stringer#String method.

func (Errors) ToError Uses

func (e Errors) ToError() error

ToError returns an error from Errors.

type FileFilter Uses

type FileFilter func(fileName string) bool

type JWTPolicy Uses

type JWTPolicy string
const (
    FirstPartyJWT JWTPolicy = "first-party-jwt"
    ThirdPartyJWT JWTPolicy = "third-party-jwt"

func DetectSupportedJWTPolicy Uses

func DetectSupportedJWTPolicy(config *rest.Config) (JWTPolicy, error)

DetectSupportedJWTPolicy queries the api-server to detect whether it has TokenRequest support

type Path Uses

type Path []string

Path is a path in slice form.

func PathFromString Uses

func PathFromString(path string) Path

PathFromString converts a string path of form a.b.c to a string slice representation.

func ToYAMLPath Uses

func ToYAMLPath(path string) Path

ToYAMLPath converts a path string to path such that the first letter of each path element is lower case.

func (Path) Equals Uses

func (p Path) Equals(p2 Path) bool

func (Path) String Uses

func (p Path) String() string

String converts a string slice path representation of form ["a", "b", "c"] to a string representation like "a.b.c".



Package util imports 31 packages (graph) and is imported by 22 packages. Updated 2020-12-21. Refresh now. Tools for package owners.