Skip to content

Commit

Permalink
Merge pull request #518 from gruntwork-io/fix-all-commands
Browse files Browse the repository at this point in the history
Exclude terragrunt-cache from xxx-all commands
  • Loading branch information
brikis98 authored Jul 10, 2018
2 parents a44fc59 + 5494508 commit a41c99c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func parseTerragruntOptionsFromArgs(args []string, writer, errWriter io.Writer)
return nil, err
}

downloadDirRaw, err := parseStringArg(args, OPT_DOWNLOAD_DIR, util.JoinPath(workingDir, ".terragrunt-cache"))
downloadDirRaw, err := parseStringArg(args, OPT_DOWNLOAD_DIR, util.JoinPath(workingDir, options.TerragruntCacheDir))
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func FindConfigFilesInPath(rootPath string) ([]string, error) {
}

if info.IsDir() {
if strings.HasPrefix(info.Name(), options.TerragruntCacheDir) {
return nil
}

configPath := DefaultConfigPath(path)
isTerragruntConfig, err := IsTerragruntConfigFile(configPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,18 @@ func TestFindConfigFilesInPathMultipleConfigs(t *testing.T) {
assert.Equal(t, expected, actual)
}

func TestFindConfigFilesIgnoresTerragruntCache(t *testing.T) {
t.Parallel()

expected := []string{
"../test/fixture-config-files/ignore-cached-config/terraform.tfvars",
}
actual, err := FindConfigFilesInPath("../test/fixture-config-files/ignore-cached-config")

assert.Nil(t, err, "Unexpected error: %v", err)
assert.Equal(t, expected, actual)
}

func mockOptionsForTestWithConfigPath(t *testing.T, configPath string) *options.TerragruntOptions {
opts, err := options.NewTerragruntOptionsForTest(configPath)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var TERRAFORM_COMMANDS_WITH_SUBCOMMAND = []string{

const DEFAULT_MAX_FOLDERS_TO_CHECK = 100

const TerragruntCacheDir = ".terragrunt-cache"

// TerragruntOptions represents options that configure the behavior of the Terragrunt program
type TerragruntOptions struct {
// Location of the Terragrunt config file
Expand Down Expand Up @@ -89,7 +91,7 @@ func NewTerragruntOptions(terragruntConfigPath string) (*TerragruntOptions, erro

logger := util.CreateLogger("")

downloadDir, err := filepath.Abs(filepath.Join(workingDir, ".terragrunt-cache"))
downloadDir, err := filepath.Abs(filepath.Join(workingDir, TerragruntCacheDir))
if err != nil {
return nil, errors.WithStackTrace(err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Intentionally empty
terragrunt = {

}

0 comments on commit a41c99c

Please sign in to comment.