Documentation ¶
Index ¶
- func CanonicalPath(path string, basePath string) (string, error)
- func CanonicalPaths(paths []string, basePath string) ([]string, error)
- func CleanPath(path string) string
- func CommaSeparatedStrings(list []string) string
- func ConvertToMap(value interface{}, keys ...string) interface{}
- func CopyFile(source string, destination string) error
- func CopyFolderContents(source, destination string, excluded ...string) error
- func DeleteFiles(files []string) error
- func EncodeBase64Sha1(str string) string
- func ExpandArguments(args []interface{}, folder string) (result []interface{})
- func FileExists(path string) bool
- func FileStat(path string) (result os.FileInfo, err error)
- func FilterList(list []string, test func(string) bool) (ret []string)
- func FromCtyValue(ctyValue cty.Value, out interface{}) error
- func GetCopy(dst, src, fileRegex string) error
- func GetPathRelativeTo(path, basePath string) (string, error)
- func GetPathRelativeToMax(path, basePath string, maxLevel uint) (result string)
- func GetPathRelativeToWorkingDir(path string) (result string)
- func GetPathRelativeToWorkingDirMax(path string, maxLevel uint) (result string)
- func GetRandomTime(lowerBound, upperBound time.Duration) time.Duration
- func GetSource(source, pwd string, logger *multilogger.Logger, fileRegex string) (string, error)
- func GetTempDownloadFolder(folders ...string) string
- func Grep(regex *regexp.Regexp, folder string, patterns ...string) (bool, error)
- func IndexOrDefault(list []string, index int, defVal string) string
- func JoinPath(elem ...string) string
- func KindOf(value interface{}) reflect.Kind
- func ListContainsElement(list []string, element string) bool
- func ListContainsElementInterface(list []interface{}, element interface{}) bool
- func LoadDefaultValues(folder string, logger *multilogger.Logger, keepInCache bool) (importedVariables map[string]interface{}, ...)
- func LoadVariables(content string, cwd string, applyTemplate bool, context ...interface{}) (map[string]interface{}, error)
- func LoadVariablesFromFile(path, cwd string, applyTemplate bool, context ...interface{}) (map[string]interface{}, error)
- func LoadVariablesFromHcl(filename string, bytes []byte) (map[string]interface{}, error)
- func LoadVariablesFromSource(content, fileName, cwd string, applyTemplate bool, context ...interface{}) (result map[string]interface{}, err error)
- func PathContainsHiddenFileOrFolder(path string) bool
- func ReadFileAsString(path string) (string, error)
- func ReadFileAsStringFromSource(source, path string, logger *multilogger.Logger) (localFile, content string, err error)
- func RemoveDuplicatesFromList(list []string, keepLast bool, getKey func(key string) string) []string
- func RemoveDuplicatesFromListKeepFirst(list []string) []string
- func RemoveDuplicatesFromListKeepLast(list []string) []string
- func RemoveElementFromList(list []string, element string) []string
- func SplitEnvVariable(str string) (key, value string, err error)
- func ToCtyValue(value interface{}) (*cty.Value, error)
- func WriteFileWithSamePermissions(source string, destination string, contents []byte) error
- type GetMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalPath ¶
CanonicalPath returns 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 ¶
CanonicalPaths returns 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 ¶
CleanPath is used to clean paths to ensure the returned path uses / as the path separator to improve cross-platform compatibility.
func CommaSeparatedStrings ¶
CommaSeparatedStrings returns an HCL compliant formatted list of strings (each string within double quote)
func ConvertToMap ¶
func ConvertToMap(value interface{}, keys ...string) interface{}
ConvertToMap builds a map with the keys supplied
func CopyFolderContents ¶
CopyFolderContents copies 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 DeleteFiles ¶
DeleteFiles deletes the given list of files. Note: this function ONLY deletes files and will return an error if you pass in a folder path.
func EncodeBase64Sha1 ¶
EncodeBase64Sha1 returns the base 64 encoded sha1 hash of the given string
func ExpandArguments ¶
func ExpandArguments(args []interface{}, folder string) (result []interface{})
ExpandArguments expands the list of arguments like x shell do
func FileExists ¶
FileExists returns true if the given file exists.
func FileStat ¶
FileStat calls os.Stat with retries When multiple projects are running in parallel, the os.Stat() function returns 'bad file descriptor' if the file is being overwritten while being read.
func FilterList ¶
FilterList returns a copy of the given list with elements that don't match the test function filtered out
func FromCtyValue ¶
FromCtyValue converts a cty Value to a go object This is a hacky workaround to convert a cty Value to a Go map[string]interface{}. cty does not support this directly (https://github.com/hashicorp/hcl2/issues/108) and doing it with gocty.FromCtyValue is nearly impossible, as cty requires you to specify all the output types and will error out when it hits interface{}. So, as an ugly workaround, we convert the given value to JSON using cty's JSON library and then convert the JSON back to a map[string]interface{} using the Go json library.
func GetCopy ¶
GetCopy is the same as Get except that it downloads a copy of the module represented by source.
This copy will omit and dot-prefixed files (such as .git/, .hg/) and can't be updated on its own.
func GetPathRelativeTo ¶
GetPathRelativeTo returns the relative path you would have to take to get from basePath to path
func GetPathRelativeToMax ¶
GetPathRelativeToMax returns either an absolute path or a relative path if it is not too far from relatively to the base path
func GetPathRelativeToWorkingDir ¶
GetPathRelativeToWorkingDir returns the path relative to the current working directory
func GetPathRelativeToWorkingDirMax ¶
GetPathRelativeToWorkingDirMax returns either an absolute path or a relative path if it is not too far from relatively to the current directory
func GetRandomTime ¶
GetRandomTime returns 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 GetSource ¶
GetSource gets the content of the source in a temporary folder and returns the local path. The function manages a cache to avoid multiple remote calls if the content has not changed. When given a local path, it is directly returned
func GetTempDownloadFolder ¶
GetTempDownloadFolder returns the fo
func Grep ¶
Grep returns true if the given regex can be found in any of the files matched by the given glob
func IndexOrDefault ¶
IndexOrDefault returns the item at index position or default value if the array is shorter than index
func JoinPath ¶
JoinPath always use / as the separator. 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 ListContainsElement ¶
ListContainsElement returns true if the given list contains the given element
func ListContainsElementInterface ¶
func ListContainsElementInterface(list []interface{}, element interface{}) bool
ListContainsElementInterface returns true if the given list contains the given element
func LoadDefaultValues ¶
func LoadDefaultValues(folder string, logger *multilogger.Logger, keepInCache bool) (importedVariables map[string]interface{}, allVariables map[string]*tfconfig.Variable, err error)
LoadDefaultValues returns a map of the variables defined in the tfvars file
func LoadVariables ¶
func LoadVariables(content string, cwd string, applyTemplate bool, context ...interface{}) (map[string]interface{}, error)
LoadVariables returns a map of the variables defined in the content provider
func LoadVariablesFromFile ¶
func LoadVariablesFromFile(path, cwd string, applyTemplate bool, context ...interface{}) (map[string]interface{}, error)
LoadVariablesFromFile returns a map of the variables defined in the tfvars file
func LoadVariablesFromHcl ¶ added in v2.2.1
LoadVariablesFromHcl parses HCL content to get a map of the attributes
func LoadVariablesFromSource ¶
func LoadVariablesFromSource(content, fileName, cwd string, applyTemplate bool, context ...interface{}) (result map[string]interface{}, err error)
LoadVariablesFromSource returns a map of the variables defined in the content provider
func PathContainsHiddenFileOrFolder ¶
PathContainsHiddenFileOrFolder returns true if folder contains files starting with . (except . and ..)
func ReadFileAsString ¶
ReadFileAsString returns the contents of the file at the given path as a string
func ReadFileAsStringFromSource ¶
func ReadFileAsStringFromSource(source, path string, logger *multilogger.Logger) (localFile, content string, err error)
ReadFileAsStringFromSource returns the contents of the file at the given path from an external source (github, s3, etc.) as a string It uses terraform to execute its command
func RemoveDuplicatesFromList ¶
func RemoveDuplicatesFromList(list []string, keepLast bool, getKey func(key string) string) []string
RemoveDuplicatesFromList returns a copy of the given list with all duplicates removed (keeping the last encountered) Params:
list: The list to filter keepLast: Indicates whether the last or first encountered duplicate element should be kept getKey: Function used to extract the actual key from the string
func RemoveDuplicatesFromListKeepFirst ¶
RemoveDuplicatesFromListKeepFirst returns a copy of the given list with all duplicates removed (keeping the first encountered)
func RemoveDuplicatesFromListKeepLast ¶
RemoveDuplicatesFromListKeepLast returns a copy of the given list with all duplicates removed (keeping the last encountered)
func RemoveElementFromList ¶
RemoveElementFromList returns a copy of the given list with all instances of the given element removed
func SplitEnvVariable ¶
SplitEnvVariable returns the two parts of an environment variable
func ToCtyValue ¶
ToCtyValue converts a go object to a cty Value This is a hacky workaround to convert a cty Value to a Go map[string]interface{}. cty does not support this directly (https://github.com/hashicorp/hcl2/issues/108) and doing it with gocty.FromCtyValue is nearly impossible, as cty requires you to specify all the output types and will error out when it hits interface{}. So, as an ugly workaround, we convert the given value to JSON using cty's JSON library and then convert the JSON back to a map[string]interface{} using the Go json library.
Types ¶
type GetMode ¶
type GetMode byte
GetMode is an enum that describes how modules are loaded.
GetModeLoad says that modules will not be downloaded or updated, they will only be loaded from the storage.
GetModeGet says that modules can be initially downloaded if they don't exist, but otherwise to just load from the current version in storage.
GetModeUpdate says that modules should be checked for updates and downloaded prior to loading. If there are no updates, we load the version from disk, otherwise we download first and then load.