Documentation ¶
Overview ¶
Package files allows to interact with files on a file system.
Index ¶
- 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 CopyFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string, ...) (string, error)
- func CopyFolderToTemp(folderPath string, tempFolderPrefix string, filter func(path string) bool) (string, error)
- func CopyTerraformFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string) (string, error)
- func CopyTerraformFolderToTemp(folderPath string, tempFolderPrefix string) (string, error)
- func CopyTerragruntFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string) (string, error)
- func CopyTerragruntFolderToTemp(folderPath string, tempFolderPrefix string) (string, error)
- func FileExists(path string) bool
- func FileExistsE(path string) (bool, error)
- func FindTerraformSourceFilesInDir(dirPath string) ([]string, error)
- func IsExistingDir(path string) bool
- func IsExistingFile(path string) bool
- func PathContainsHiddenFileOrFolder(path string) bool
- func PathContainsTerraformState(path string) bool
- func PathContainsTerraformStateOrVars(path string) bool
- func PathIsTerraformVersionFile(path string) bool
- func WriteFileWithSamePermissions(source string, destination string, contents []byte) error
- type DirNotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFolderContents ¶
CopyFolderContents copies all the files and folders within the given source folder to the destination folder.
func CopyFolderContentsWithFilter ¶
func CopyFolderContentsWithFilter(source string, destination string, filter func(path string) bool) error
CopyFolderContentsWithFilter copies the files and folders within the given source folder that pass the given filter (return true) to the destination folder.
func CopyFolderToDest ¶ added in v0.40.3
func CopyFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string, filter func(path string) bool) (string, error)
CopyFolderToDest creates a copy of the given folder and all its filtered contents in a temp folder with a unique name and the given prefix.
func CopyFolderToTemp ¶ added in v0.15.12
func CopyFolderToTemp(folderPath string, tempFolderPrefix string, filter func(path string) bool) (string, error)
CopyFolderToTemp calls CopyFolderToDest, passing os.TempDir() as the root destination folder.
func CopyTerraformFolderToDest ¶ added in v0.40.3
func CopyTerraformFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string) (string, error)
CopyTerraformFolderToDest creates a copy of the given folder and all its contents in a specified folder with a unique name and the given prefix. This is useful when running multiple tests in parallel against the same set of Terraform files to ensure the tests don't overwrite each other's .terraform working directory and terraform.tfstate files. This method returns the path to the dest folder with the copied contents. Hidden files and folders (with the exception of the `.terraform-version` files used by the [tfenv tool](https://github.com/tfutils/tfenv)), Terraform state files, and terraform.tfvars files are not copied to this temp folder, as you typically don't want them interfering with your tests. This method is useful when running through a build tool so the files are copied to a destination that is cleaned on each run of the pipeline.
func CopyTerraformFolderToTemp ¶
CopyTerraformFolderToTemp calls CopyTerraformFolderToDest, passing os.TempDir() as the root destination folder.
func CopyTerragruntFolderToDest ¶ added in v0.40.3
func CopyTerragruntFolderToDest(folderPath string, destRootFolder string, tempFolderPrefix string) (string, error)
CopyTerragruntFolderToDest creates a copy of the given folder and all its contents in a specified folder with a unique name and the given prefix. Since terragrunt uses tfvars files to specify modules, they are copied to the directory as well. Terraform state files are excluded as well as .terragrunt-cache to avoid overwriting contents.
func CopyTerragruntFolderToTemp ¶ added in v0.15.12
CopyTerragruntFolderToTemp calls CopyTerragruntFolderToDest, passing os.TempDir() as the root destination folder.
func FileExists ¶
FileExists returns true if the given file exists.
func FileExistsE ¶ added in v0.19.5
FileExistsE returns true if the given file exists It will return an error if os.Stat error is not an ErrNotExist
func FindTerraformSourceFilesInDir ¶ added in v0.38.1
FindTerraformSourceFilesInDir given a directory path, finds all the terraform source files contained in it. This will recursively search subdirectories, but will ignore any hidden files (which in turn ignores terraform data dirs like .terraform folder).
func IsExistingDir ¶ added in v0.30.22
IsExistingDir returns true if the path exists and is a directory
func IsExistingFile ¶ added in v0.30.22
IsExistingFile returns true if the path exists and is a file.
func PathContainsHiddenFileOrFolder ¶
PathContainsHiddenFileOrFolder returns true if the given path contains a hidden file or folder.
func PathContainsTerraformState ¶ added in v0.15.12
PathContainsTerraformState returns true if the path corresponds to a Terraform state file.
func PathContainsTerraformStateOrVars ¶
PathContainsTerraformStateOrVars returns true if the path corresponds to a Terraform state file or .tfvars/.tfvars.json file.
func PathIsTerraformVersionFile ¶ added in v0.38.8
PathIsTerraformVersionFile returns true if the given path is the special '.terraform-version' file used by the [tfenv](https://github.com/tfutils/tfenv) tool.
Types ¶
type DirNotFoundError ¶ added in v0.32.1
type DirNotFoundError struct {
Directory string
}
DirNotFoundError is an error that occurs if a directory doesn't exist
func (DirNotFoundError) Error ¶ added in v0.32.1
func (err DirNotFoundError) Error() string