Documentation ¶
Index ¶
- Constants
- Variables
- func ConsolidateLog(logMessage string) string
- func CreateNamespace(cs kubernetes.Interface, namespace string, network string, dryRun bool) error
- func DeleteFromMap(parentMap any, key any) error
- func DeleteFromSlicePtr(parentSlice any, index int) error
- func EqualErrors(a, b Errors) bool
- func FindFiles(path string, filter FileFilter) ([]string, error)
- func GKString(gvk schema.GroupKind) string
- func InsertIntoMap(parentMap any, key any, value any) error
- func IsEmptyString(value any) bool
- func IsFilePath(path string) bool
- func IsHTTPURL(path string) (bool, error)
- func IsIntKind(k reflect.Kind) bool
- func IsKVPathElement(pe string) bool
- func IsMap(value any) bool
- func IsMapPtr(v any) bool
- func IsNPathElement(pe string) bool
- func IsNilOrInvalidValue(v reflect.Value) bool
- func IsPtr(value any) bool
- func IsSlice(value any) bool
- func IsSliceInterfacePtr(v any) bool
- func IsSlicePtr(v any) bool
- func IsString(value any) bool
- func IsStruct(value any) bool
- func IsTypeInterface(t reflect.Type) bool
- func IsTypeMap(t reflect.Type) bool
- func IsTypeSliceOfInterface(t reflect.Type) bool
- func IsTypeSlicePtr(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 any) bool
- func IsValueNilOrDefault(value any) 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 IsYAMLEmpty(y string) bool
- func IsYAMLEqual(a, b string) bool
- func MarshalWithJSONPB(val proto.Message) (string, error)
- func MustStruct(m map[string]any) *structpb.Struct
- func MustToYAMLGeneric(root any) string
- func OverlayIOP(base, overlay string) (string, error)
- func OverlayTrees(base map[string]any, overlays ...map[string]any) (map[string]any, error)
- func OverlayYAML(base, overlay string) (string, error)
- func ParseValue(valueStr string) any
- func PathKV(pe string) (k, v string, err error)
- func PathN(pe string) (int, error)
- func PathV(pe string) (string, error)
- func PrometheusPathAndPort(pod *v1.Pod) (string, int, error)
- func ReadFilesWithFilter(path string, filter FileFilter) (string, error)
- func RemoveBrackets(pe string) (string, bool)
- func RenderTemplate(tmpl string, ts any) (string, error)
- func SetLabel(resource runtime.Object, label, value string) error
- func StringBoolMapToSlice(m map[string]bool) []string
- func ToIntValue(val any) (int, bool)
- func ToString(errors []error, separator string) string
- func ToYAML(val any) string
- func ToYAMLGeneric(root any) ([]byte, error)
- func ToYAMLPathString(path string) string
- func ToYAMLWithJSONPB(val proto.Message) string
- func UnmarshalWithJSONPB(y string, out proto.Message, allowUnknownField bool) error
- func UpdateSlicePtr(parentSlice any, index int, value any) error
- func ValidateIOPCAConfig(client kube.Client, iop *iopv1alpha1.IstioOperator) error
- func ValueString(v *structpb.Value) string
- func ValuesAreSameType(v1 reflect.Value, v2 reflect.Value) bool
- func YAMLDiff(a, b string) string
- type Errors
- type FileFilter
- type Path
Constants ¶
const ( // PathSeparator is the separator between path elements. PathSeparator = "." // 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 )
Variables ¶
var ValidKeyRegex = regexp.MustCompile("^[a-zA-Z0-9_-]*$")
ValidKeyRegex is a regex for a valid path key element.
Functions ¶
func ConsolidateLog ¶
ConsolidateLog is a helper function to dedup the log message.
func CreateNamespace ¶
CreateNamespace creates a namespace using the given k8s interface.
func DeleteFromMap ¶
DeleteFromMap deletes an entry with the given key parent, which must be a map.
func DeleteFromSlicePtr ¶
DeleteFromSlicePtr deletes an entry at index from the parent, which must be a slice ptr.
func EqualErrors ¶
EqualErrors reports whether a and b are equal, regardless of ordering.
func FindFiles ¶
func FindFiles(path string, filter FileFilter) ([]string, error)
FindFiles reads files from path, and returns the file names that match the filter.
func InsertIntoMap ¶
InsertIntoMap inserts value with key into parent which must be a map, map ptr, or interface to map.
func IsEmptyString ¶
IsEmptyString returns true if value is an empty string.
func IsFilePath ¶
IsFilePath reports whether the given URL is a local file path.
func IsKVPathElement ¶
IsKVPathElement report whether pe is a key/value path element.
func IsNPathElement ¶
IsNPathElement report whether pe is an index path element.
func IsNilOrInvalidValue ¶
IsNilOrInvalidValue reports whether v is nil or reflect.Zero.
func IsSliceInterfacePtr ¶
IsSliceInterfacePtr reports whether v is a slice ptr type.
func IsTypeInterface ¶
IsTypeInterface reports whether v is an interface.
func IsTypeSliceOfInterface ¶
IsTypeSliceOfInterface reports whether v is a slice of interface.
func IsTypeSlicePtr ¶
IsTypeSlicePtr reports whether v is a slice ptr 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 ¶
IsValueNil returns true if either value is nil, or has dynamic type {ptr, map, slice} with value nil.
func IsValueNilOrDefault ¶
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 IsYAMLEmpty ¶
IsYAMLEmpty reports whether the YAML string y is logically empty.
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 MustToYAMLGeneric ¶
func OverlayIOP ¶
OverlayIOP overlays over base using JSON strategic merge.
func OverlayTrees ¶
OverlayTrees performs a sequential JSON strategic of overlays over base.
func OverlayYAML ¶
OverlayYAML patches the overlay tree over the base tree and returns the result. All trees are expressed as YAML strings.
func PathKV ¶
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 ¶
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 ¶
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 ¶
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 ¶
RemoveBrackets removes the [] around pe and returns the resulting string. It returns false if pe is not surrounded by [].
func RenderTemplate ¶
RenderTemplate is a helper method to render a template with the given values.
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, with elements separated by separator string. Any nil errors in the slice are skipped.
func ToYAML ¶
ToYAML returns a YAML string representation of val, or the error string if an error occurs.
func ToYAMLGeneric ¶
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 gogo 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 ValidateIOPCAConfig ¶
func ValidateIOPCAConfig(client kube.Client, iop *iopv1alpha1.IstioOperator) error
ValidateIOPCAConfig validates if the IstioOperator CA configs are applicable to the K8s cluster
func ValueString ¶
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.