util

package
v0.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMaps added in v0.9.0

func CompareMaps(existing, new map[string]string) bool

func CompareMapsWithExceptions added in v0.23.0

func CompareMapsWithExceptions(existing, new map[string]string, prefixExceptions ...string) bool

CompareMapsWithExceptions compares two maps but ignoring any differences where the keys are prefixed with any of the 'prefixExceptions'

func CompareStructNumTypeAgnostic added in v0.13.0

func CompareStructNumTypeAgnostic(src, dst any) bool

CompareStructNumTypeAgnostic compares two structs, ignoring the type of numbers (e.g., int, float32, float64) and treating them as equal if their values are equal.

func ExtractPath added in v0.8.0

func ExtractPath(data any, path []string) (any, bool, error)

ExtractPath extracts the fields specified by the path (given as slice of strings) from the given data.

The function takes two arguments:

  • data: The input data, which can be a map, a slice, or a nested combination of both.
  • path: A slice of strings representing the path to the desired fields.

It returns three values:

  • any: The extracted data, which can be a map, a slice, or a single value (including nil).
  • bool: A boolean indicating whether last field in the path is a map.
  • error: An error if any occurred during the extraction process.

The function works by recursively traversing the input data according to the provided path. It handles maps and slices, extracting the corresponding values at each level. If the path leads to a value that is neither a map nor a slice, it returns that value.

func IsNumber added in v0.19.0

func IsNumber(value any) bool

func MergeMaps added in v0.9.0

func MergeMaps(existing, new map[string]string) map[string]string

func NewWorkQueue added in v0.2.0

func NewWorkQueue(queueName string) workqueue.TypedRateLimitingInterface[interface{}]

func OptionalString added in v0.13.0

func OptionalString(ptr any) string

take any pointer passed in and print "nil" if it's nil, and otherwise the value (convenience function for logging)

func RemovePaths added in v0.7.0

func RemovePaths(m map[string]any, excludedPaths []string, pathSeparator string)

RemovePaths removes all of the excludedPaths passed in from m, where each excludedPath is a string representation of the path, demarcated by pathSeparator

func ResolveTemplateSpec added in v0.22.0

func ResolveTemplateSpec(data any, args map[string]interface{}) (map[string]interface{}, error)

resolves templated definitions of a resource with any arguments

func StructToStruct added in v0.2.0

func StructToStruct(src any, dst any) error

StructToStruct converts a struct type (src) into another (dst)

func ToFloat64 added in v0.19.0

func ToFloat64(value any) (float64, bool)

func ToInt64 added in v0.19.0

func ToInt64(value any) (int64, bool)

ToInt64 returns the int64 value, assuming that it can be cast as one Returns boolean for whether it can be cast as one

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL