Documentation ¶
Overview ¶
Package util contains various utility methods for working with data (slice, map, nested map, string, time) as well as system-level primitives (files, exec).
Index ¶
- Constants
- func ComparePasswords(hashedPassword string, password string) bool
- func ContainsString(a []string, v string) bool
- func CopySliceOfStrings(a []string) []string
- func CountElements(m interface{}) int
- func EscapeName(str string) string
- func FindYamlFiles(filePaths []string) ([]string, error)
- func GetSortedStringKeys(m interface{}) []string
- func HashAndSalt(password string) string
- func HashFnv(s string) uint32
- func ProcessIncludeMacros(node NestedParameterMap, baseDir string) error
- func RandomID(rand *rand.Rand, length int) string
- func RunCmd(cmdName string, cmdArgs ...string) (string, error)
- func StringContainsAny(str string, substrings ...string) bool
- func WriteTempFile(prefix string, data []byte) string
- type NestedParameterMap
- func (src NestedParameterMap) DeepEqual(dst NestedParameterMap) bool
- func (src NestedParameterMap) Diff(dst NestedParameterMap) string
- func (src NestedParameterMap) GetNestedMap(key string) NestedParameterMap
- func (src NestedParameterMap) GetString(key string, defaultValue string) (string, error)
- func (src NestedParameterMap) MakeCopy() NestedParameterMap
- func (src *NestedParameterMap) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
const ( // ModeCompile just compiles all text templates on parameter tree without evaluating ModeCompile = iota // ModeEvaluate evaluates the whole parameter tree and all of its text templates, given a set of parameters ModeEvaluate = iota )
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶ added in v0.1.6
ComparePasswords verifies hashed password
func ContainsString ¶
ContainsString checks if a slice of strings contains a given string
func CopySliceOfStrings ¶
CopySliceOfStrings makes a copy of a given slice of strings
func CountElements ¶
func CountElements(m interface{}) int
CountElements returns the number of elements in the structure, processing it recursively It adds up number elements in underlying maps and slices/arrays
func EscapeName ¶
EscapeName escapes provided string by replacing # and _ with -
func FindYamlFiles ¶ added in v0.1.11
FindYamlFiles returns all files found for given list of file paths that could be of the following types: * specific file path * directory (then all *.yaml files will be taken from it and all subdirectories) * file pattern like
func GetSortedStringKeys ¶
func GetSortedStringKeys(m interface{}) []string
GetSortedStringKeys assumes m is a map[string]interface{} and returns an array of sorted keys
func HashAndSalt ¶ added in v0.1.6
HashAndSalt returns salted hash from the password (only used to generate user passwords)
func ProcessIncludeMacros ¶ added in v0.1.11
func ProcessIncludeMacros(node NestedParameterMap, baseDir string) error
ProcessIncludeMacros walks through specified NestedParameterMap and resolves @include macros
func StringContainsAny ¶
StringContainsAny returns if string contains any of the given substrings
func WriteTempFile ¶
WriteTempFile creates a temporary file, writes given data into it and returns its name. It's up to a caller to delete the created temporary file by calling os.Remove() on its name.
Types ¶
type NestedParameterMap ¶
type NestedParameterMap map[string]interface{}
NestedParameterMap is a nested map of parameters, which allows to work with maps [string][string]...[string] -> string, int, bool values
func ProcessParameterTree ¶
func ProcessParameterTree(tree NestedParameterMap, parameters *template.Parameters, cache *template.Cache, mode int) (NestedParameterMap, error)
ProcessParameterTree processes NestedParameterMap and calculates the whole tree, assuming values are text templates
func (NestedParameterMap) DeepEqual ¶
func (src NestedParameterMap) DeepEqual(dst NestedParameterMap) bool
DeepEqual compares two nested parameter maps If both maps are empty (have zero elements), the method will return true
func (NestedParameterMap) Diff ¶
func (src NestedParameterMap) Diff(dst NestedParameterMap) string
Diff returns a human-readable diff between two nested parameter maps
func (NestedParameterMap) GetNestedMap ¶
func (src NestedParameterMap) GetNestedMap(key string) NestedParameterMap
GetNestedMap returns nested parameter map by key
func (NestedParameterMap) GetString ¶
func (src NestedParameterMap) GetString(key string, defaultValue string) (string, error)
GetString returns string located by provided key
func (NestedParameterMap) MakeCopy ¶
func (src NestedParameterMap) MakeCopy() NestedParameterMap
MakeCopy makes a shallow copy of parameter structure
func (*NestedParameterMap) UnmarshalYAML ¶
func (src *NestedParameterMap) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is a custom unmarshal function for NestedParameterMap to deal with interface{} -> string conversions