utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package utils has a number of useful operations that are used in multiple places of the inspr packages, contains operations such as:

  • go-cmp: "comparators and evaluator for slices and maps"
  • string_slice: "set of operations of custom string slice"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneralCompareOptions

func GeneralCompareOptions() cmp.Options

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 GetMapCompareOptions

func GetMapCompareOptions() cmp.Options

GetMapCompareOptions - returns opts for cmd.Equal ignores all slices and compares maps

func Includes

func Includes(vs []string, t string) bool

Includes returns true if the target string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string t, or -1 if no match is found.

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function f to each string in the original slice.

func Remove

func Remove(vs []string, t string) []string

Remove return a new slice without any occurrence of the target string t

func StringSliceUnion

func StringSliceUnion(a, b []string) []string

StringSliceUnion returns the sorted union of the two string slices. Remember that union dont have repeated elements

Types

type EnvironmentMap

type EnvironmentMap map[string]string

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) Join

func (c StringArray) Join(sep string) string

Join joins a string array with a given separator, returning the string generated

func (StringArray) Map

func (c StringArray) Map(f func(string) string) StringArray

Map maps a given function into another string array

func (StringArray) Union

func (c StringArray) Union(other StringArray) StringArray

Union returns the union of a string array with another

Jump to

Keyboard shortcuts

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