common

package
v0.0.0-...-f7ae98d Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(URL, destFile string) error

func FileExists

func FileExists(path string) bool

FileExists returns true if the file @ path exists

func IsDir

func IsDir(path string) bool

IsDir returns true if the object @ path is a dir

func IsFile

func IsFile(path string) bool

IsFile returns true if the object @ path is a file

func IsURL

func IsURL(s string) bool

func MapInterfaceInterfaceToMapStringInterface

func MapInterfaceInterfaceToMapStringInterface(mapInterfaceInterface map[interface{}]interface{}) map[string]interface{}

MapInterfaceInterfaceToMapStringInterface recursively converts map[interface{}]interface{} to map[string]interface{}

func MapStringInterfaceGetOrDefault

func MapStringInterfaceGetOrDefault(mapStringInterface map[string]interface{}, key string, defaultValue interface{}) interface{}

MapStringInterfaceGetIntOrDefault will return the key as an integer or return a default

func MapToSlice

func MapToSlice(m map[string]interface{}) []interface{}

MapToSlice converts {key1: val1, key2: val2 ...} to [key1, val1, key2, val2 ...]

func Redact

func Redact(redactions []string, runOutput string) string

func RemoveEmptyLines

func RemoveEmptyLines(input string) string

RemoveEmptyLines removes all empty lines from a string

func RetryUntilSuccessful

func RetryUntilSuccessful(duration time.Duration, interval time.Duration, callback func() bool) error

RetryUntilSuccessful calls callback every interval for duration until it returns true

func RunningInContainer

func RunningInContainer() bool

RunningInContainer returns true if currently running in a container, false otherwise

func StringMapToString

func StringMapToString(source map[string]string) string

StringMapToString converts a map of a: x, b: y to a string in the form of "a=x,b=y"

func StringSliceToIntSlice

func StringSliceToIntSlice(stringSlice []string) ([]int, error)

StringSliceToIntSlice converts slices of strings to slices of int. e.g. ["1", "3"] -> [1, 3]

func StringToStringMap

func StringToStringMap(source string, separator string) map[string]string

StringToStringMap converts a string in the form of a{separator}x,b{separator}y to a map of a: x, b: y, inputs source-string & string-separator

func StripPrefixes

func StripPrefixes(input string, prefixes []string) string

func StructureToMap

func StructureToMap(input interface{}) map[string]interface{}

StructureToMap converts a strcuture to a map, flattening all members

func TempFileSuffix

func TempFileSuffix(dir, suffix string) (f *os.File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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