Skip to content

Commit

Permalink
Fix built-in find_in_parent_folders func (#2869)
Browse files Browse the repository at this point in the history
* fix: findInParentFolders func

* fix: revert code for the `findInParentFolder` function
  • Loading branch information
levkohimins authored Dec 26, 2023
1 parent b1b7ce1 commit e5081e1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,11 @@ func findInParentFolders(
return "", errors.WithStackTrace(ParentFileNotFound{Path: terragruntOptions.TerragruntConfigPath, File: fileToFindStr, Cause: "Traversed all the way to the root"})
}

fileToFind := currentDir

fileToFind := GetDefaultConfigPath(currentDir)
if fileToFindParam != "" {
fileToFind = util.JoinPath(currentDir, fileToFindParam)
}

// if `fileToFind` is dir, append default config filename `terragrunt.hcl`
fileToFind = GetDefaultConfigPath(fileToFind)

if util.FileExists(fileToFind) {
return fileToFind, nil
}
Expand Down
6 changes: 6 additions & 0 deletions config/config_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ func TestFindInParentFolders(t *testing.T) {
absPath(t, "../test/fixture-parent-folders/in-another-subfolder/common/foo.txt"),
nil,
},
{
[]string{"tfwork"},
terragruntOptionsForTest(t, "../test/fixture-parent-folders/with-params/tfwork/tg/"+DefaultTerragruntConfigPath),
absPath(t, "../test/fixture-parent-folders/with-params/tfwork"),
nil,
},
{
nil,
terragruntOptionsForTest(t, "/"),
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include "module" {
path = "${find_in_parent_folders("tfwork")}/test-var/providers.tf"
}

0 comments on commit e5081e1

Please sign in to comment.