Documentation ¶
Index ¶
- func BashCmdExec(cmd string, workingDir string, environ []string, logPrefix string) error
- func CmdExec(cmdName string, cmdArgs []string, workingDir string, environ []string, ...) error
- func CopyDir(src string, dst string) (err error)
- func CopyFile(src, dst string) (err error)
- func ExpandPath(filePath string) (string, error)
- func FileDelete(filePath string) error
- func FileExists(filePath string) bool
- func FileWrite(filePath string, content string, perm os.FileMode, dryRun bool) error
- func GetEnv(key string, defaultVal string) string
- func GetEnvAsBool(name string, defaultVal bool) bool
- func GetEnvAsInt(name string, defaultVal int) int
- func GetEnvAsSlice(name string, defaultVal []string, sep string) []string
- func LeftPad(s string, padStr string, pLen int) string
- func LeftPad2Len(s string, padStr string, overallLen int) string
- func MapDeepCopy(m map[string]interface{}) (map[string]interface{}, error)
- func MapKeys(m map[string]interface{}) []string
- func MapMerge(maps ...map[string]string) map[string]string
- func MapMergeGeneric(maps ...map[string]interface{}) map[string]interface{}
- func PopulatePathTemplate(pathTmplContent string, data interface{}) (string, error)
- func PopulateTemplate(tmplContent string, data interface{}) (string, error)
- func RightPad(s string, padStr string, pLen int) string
- func RightPad2Len(s string, padStr string, overallLen int) string
- func SliceIncludes(slice []string, item string) bool
- func SnakeCaseToCamelCase(inputUnderScoreStr string) (camelCase string)
- func StdinQuery(question string) string
- func StdinQueryBoolean(question string) bool
- func StdinQueryInt(question string) (int, error)
- func StdinQueryPassword(question string) (string, error)
- func StringToInt(input string) (int, error)
- func StringifyYAMLMapKeys(in interface{}) interface{}
- func StripIndent(multilineStr string) string
- func UniquePort(data interface{}) (int, error)
- func UnsetEnv(prefix string) (restore func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BashCmdExec ¶
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.
func CopyFile ¶
CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.
func ExpandPath ¶
func FileDelete ¶
func FileExists ¶
func GetEnvAsBool ¶
Helper to read an environment variable into a bool or return default value
func GetEnvAsInt ¶
Simple helper function to read an environment variable into integer or return a default value
func GetEnvAsSlice ¶
Helper to read an environment variable into a string slice or return default value
func MapDeepCopy ¶
func MapMergeGeneric ¶
func PopulatePathTemplate ¶
func PopulateTemplate ¶
func SliceIncludes ¶
func SnakeCaseToCamelCase ¶
func StdinQuery ¶
func StdinQueryBoolean ¶
func StdinQueryInt ¶
func StdinQueryPassword ¶
func StringToInt ¶
func StringifyYAMLMapKeys ¶
func StringifyYAMLMapKeys(in interface{}) interface{}
stringifyKeysMapValue recurses into in and changes all instances of map[interface{}]interface{} to map[string]interface{}. This is useful to work around the impedence mismatch between JSON and YAML unmarshaling that's described here: https://github.com/go-yaml/yaml/issues/139
Inspired by https://github.com/stripe/stripe-mock, MIT licensed
func StripIndent ¶
func UniquePort ¶
func UnsetEnv ¶
func UnsetEnv(prefix string) (restore func())
UnsetEnv unsets all envars having prefix and returns a function that restores the env. Any newly added envars having prefix are also unset by restore. It is idiomatic to use with a defer.
defer UnsetEnv("ACME_")()
Note that modifying the env may have unpredictable results when tests are run with t.Parallel. NOTE: This is quick n' dirty from memory; write some tests for this code.
Types ¶
This section is empty.