Documentation ¶
Index ¶
- Constants
- func CanonicalPath(path string, basePath string) (string, error)
- func CanonicalPaths(paths []string, basePath string) ([]string, error)
- func CleanPath(path string) string
- func CloneStringList(listToClone []string) []string
- func CloneStringMap(mapToClone map[string]string) map[string]string
- func CommaSeparatedStrings(list []string) string
- func CopyFile(source string, destination string) error
- func CopyFolderContents(source string, destination string) error
- func CopyFolderContentsWithFilter(source string, destination string, filter func(path string) bool) error
- func CreateLogger(prefix string) *log.Logger
- func CreateLoggerWithWriter(writer io.Writer, prefix string) *log.Logger
- func DeleteFiles(files []string) error
- func DoWithRetry(actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, ...) error
- func EncodeBase64Sha1(str string) string
- func FileExists(path string) bool
- func FirstArg(args []string) string
- func GetPathRelativeTo(path string, basePath string) (string, error)
- func GetRandomTime(lowerBound, upperBound time.Duration) time.Duration
- func Grep(regex *regexp.Regexp, glob string) (bool, error)
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsSymLink(path string) bool
- func JoinPath(elem ...string) string
- func JoinTerraformModulePath(modulesFolder string, path string) string
- func KindOf(value interface{}) reflect.Kind
- func LastArg(args []string) string
- func ListContainsElement(list []string, element string) bool
- func MatchesAny(regExps []string, s string) bool
- func Min(x, y int) int
- func PathContainsHiddenFileOrFolder(path string) bool
- func ReadFileAsString(path string) (string, error)
- func RemoveDuplicatesFromList(list []string) []string
- func RemoveDuplicatesFromListKeepLast(list []string) []string
- func RemoveElementFromList(list []string, element string) []string
- func SecondArg(args []string) string
- func UniqueId() string
- func WriteFileWithSamePermissions(source string, destination string, contents []byte) error
- type MaxRetriesExceeded
Constants ¶
const BASE_62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const UNIQUE_ID_LENGTH = 6 // Should be good for 62^6 = 56+ billion combinations
Variables ¶
This section is empty.
Functions ¶
func CanonicalPath ¶ added in v0.6.0
Return the canonical version of the given path, relative to the given base path. That is, if the given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.
func CanonicalPaths ¶ added in v0.6.0
Return the canonical version of the given paths, relative to the given base path. That is, if a given path is a relative path, assume it is relative to the given base path. A canonical path is an absolute path with all relative components (e.g. "../") fully resolved, which makes it safe to compare paths as strings.
func CleanPath ¶ added in v0.9.0
Use this function when cleaning paths to ensure the returned path uses / as the path separator to improve cross-platform compatibility
func CloneStringList ¶ added in v0.13.19
Make a copy of the given list of strings
func CloneStringMap ¶ added in v0.13.19
Make a copy of the given map of strings
func CommaSeparatedStrings ¶ added in v0.12.17
CommaSeparatedStrings returns an HCL compliant formatted list of strings (each string within double quote)
func CopyFolderContents ¶ added in v0.9.4
Copy the files and folders within the source folder into the destination folder. Note that hidden files and folders (those starting with a dot) will be skipped.
func CopyFolderContentsWithFilter ¶ added in v0.19.0
func CopyFolderContentsWithFilter(source string, destination string, filter func(path string) bool) error
Copy the files and folders within the source folder into the destination folder. Pass each file and folder through the given filter function and only copy it if the filter returns true.
func CreateLogger ¶ added in v0.6.0
Create a logger with the given prefix
func CreateLoggerWithWriter ¶ added in v0.13.3
CreateLoggerWithWriter Create a logger around the given output stream and prefix
func DeleteFiles ¶ added in v0.9.7
Delete the given list of files. Note: this function ONLY deletes files and will return an error if you pass in a folder path.
func DoWithRetry ¶ added in v0.19.0
func DoWithRetry(actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, logger *log.Logger, action func() error) error
DoWithRetry runs the specified action. If it returns a value, return that value. If it returns an error, sleep for sleepBetweenRetries and try again, up to a maximum of maxRetries retries. If maxRetries is exceeded, return a MaxRetriesExceeded error.
func EncodeBase64Sha1 ¶ added in v0.9.7
Returns the base 64 encoded sha1 hash of the given string
func FirstArg ¶ added in v0.16.7
A convenience method that returns the first item (0th index) in the given list or an empty string if this is an empty list
func GetPathRelativeTo ¶ added in v0.4.0
Return the relative path you would have to take to get from basePath to path
func GetRandomTime ¶ added in v0.6.4
Get a random time duration between the lower bound and upper bound. This is useful because some of our automated tests wound up flooding the AWS API all at once, leading to a "Subscriber limit exceeded" error. TODO: Some of the more exotic test cases fail, but it's not worth catching them given the intended use of this function.
func Grep ¶
Returns true if the given regex can be found in any of the files matched by the given glob
func IsSymLink ¶ added in v0.19.0
IsSymLink returns true if the given file is a symbolic link Per https://stackoverflow.com/a/18062079/2308858
func JoinPath ¶ added in v0.9.0
Windows systems use \ as the path separator *nix uses / Use this function when joining paths to force the returned path to use / as the path separator This will improve cross-platform compatibility
func JoinTerraformModulePath ¶ added in v0.13.13
Join two paths together with a double-slash between them, as this is what Terraform uses to identify where a "repo" ends and a path within the repo begins. Note: The Terraform docs only mention two forward-slashes, so it's not clear if on Windows those should be two back-slashes? https://www.terraform.io/docs/modules/sources.html
func LastArg ¶ added in v0.16.14
A convenience method that returns the last item in the given list or an empty string if this is an empty list
func ListContainsElement ¶ added in v0.6.0
Return true if the given list contains the given element
func MatchesAny ¶ added in v0.17.0
func PathContainsHiddenFileOrFolder ¶ added in v0.12.22
func ReadFileAsString ¶ added in v0.4.0
Return the contents of the file at the given path as a string
func RemoveDuplicatesFromList ¶ added in v0.12.11
Returns a copy of the given list with all duplicates removed (keeping the first encountereds)
func RemoveDuplicatesFromListKeepLast ¶ added in v0.12.11
Returns a copy of the given list with all duplicates removed (keeping the last encountereds)
func RemoveElementFromList ¶ added in v0.6.0
Return a copy of the given list with all instances of the given element removed
func SecondArg ¶ added in v0.16.7
A convenience method that returns the second item (1st index) in the given list or an empty string if this is a list that has less than 2 items in it
func UniqueId ¶ added in v0.19.0
func UniqueId() string
Returns a unique (ish) id we can use to name resources so they don't conflict with each other. Uses base 62 to generate a 6 character string that's unlikely to collide with the handful of tests we run in parallel. Based on code here: http://stackoverflow.com/a/9543797/483528
Types ¶
type MaxRetriesExceeded ¶ added in v0.19.0
MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.
func (MaxRetriesExceeded) Error ¶ added in v0.19.0
func (err MaxRetriesExceeded) Error() string