Documentation ¶
Overview ¶
Package utils has a number of useful operations that are used in multiple places of the inspr packages, contains operations such as:
- compare_options: "comparators and evaluator for slices and maps"
- string_slice: "set of operations of custom string slice"
Index ¶
- func GeneralCompareOptions() cmp.Options
- func GetFreePorts(count int) ([]int, error)
- func GetMapCompareOptions() cmp.Options
- func Includes(vs []string, t string) bool
- func Index(vs []string, t string) int
- func Map(vs []string, f func(string) string) []string
- func Remove(vs []string, t string) []string
- func StringSliceUnion(a, b []string) []string
- type EnvironmentMap
- type StringArray
- func (c StringArray) Contains(item string) bool
- func (c StringArray) Filter(f func(string) bool) StringArray
- func (c StringArray) Join(sep string) string
- func (c StringArray) Len() int
- func (c StringArray) Less(i, j int) bool
- func (c StringArray) Map(f func(string) string) StringArray
- func (c StringArray) Sorted() StringArray
- func (c StringArray) Swap(i, j int)
- func (c StringArray) Union(other StringArray) StringArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneralCompareOptions ¶
GeneralCompareOptions - returns opts for cmd.Equal ignores all slices and maps inside a struct.
While not being ideal it removes the maps and slices from the reflect.Equal.
func GetFreePorts ¶
GetFreePorts asks the kernel for free open ports that are ready to use
func GetMapCompareOptions ¶
GetMapCompareOptions - returns opts for cmd.Equal ignores all slices and compares maps
func Map ¶
Map returns a new slice containing the results of applying the function f to each string in the original slice.
func StringSliceUnion ¶
StringSliceUnion returns the sorted union of the two string slices. Remember that union dont have repeated elements
Types ¶
type EnvironmentMap ¶
EnvironmentMap is a type for environment variables represented as a map
func ParseFromK8sEnvironment ¶
func ParseFromK8sEnvironment(envs []kubeCore.EnvVar) EnvironmentMap
ParseFromK8sEnvironment is the oposing function to ParseToK8sArrEnv.
func (EnvironmentMap) ParseToK8sArrEnv ¶
func (m EnvironmentMap) ParseToK8sArrEnv() []kubeCore.EnvVar
ParseToK8sArrEnv parses the map into an array of kubernetes' environment variables
type StringArray ¶
type StringArray []string
StringArray is an array of strings with functional and set-like helper methods
func (StringArray) Contains ¶
func (c StringArray) Contains(item string) bool
Contains returns whether or not an array contains an item
func (StringArray) Filter ¶ added in v0.1.3
func (c StringArray) Filter(f func(string) bool) StringArray
Filter creates a new string array without the filtered items
func (StringArray) Join ¶
func (c StringArray) Join(sep string) string
Join joins a string array with a given separator, returning the string generated
func (StringArray) Len ¶ added in v0.1.3
func (c StringArray) Len() int
func (StringArray) Less ¶ added in v0.1.3
func (c StringArray) Less(i, j int) bool
func (StringArray) Map ¶
func (c StringArray) Map(f func(string) string) StringArray
Map maps a given function into another string array
func (StringArray) Sorted ¶ added in v0.1.3
func (c StringArray) Sorted() StringArray
Sorted is a helper method that sorts an String Array
func (StringArray) Swap ¶ added in v0.1.3
func (c StringArray) Swap(i, j int)
func (StringArray) Union ¶
func (c StringArray) Union(other StringArray) StringArray
Union returns the union of a string array with another