Skip to content

Commit

Permalink
fix(dry): set originalterragruntdir
Browse files Browse the repository at this point in the history
Fixes the issue when calling get_original_terragrunt_dir
  • Loading branch information
Benjamin Sanvoisin committed Jan 28, 2024
1 parent 2e1a6f6 commit 1f014d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions checks/dry.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ func findFilesInLayers(path string) ([]string, error) {
files := []string{}
// Create new terragrunt option scoped to the file we are scanning
options, _ := options.NewTerragruntOptionsWithConfigPath(path)
options.OriginalTerragruntConfigPath = path
// Parse the file with PartialParseConfigFile which parse all essential block, in our case local and include
// https://github.com/gruntwork-io/terragrunt/blob/master/config/config_partial.go#L147
terragruntConfig, err := config.PartialParseConfigFile(path, options, nil, []config.PartialDecodeSectionType{
config.DependenciesBlock,
config.DependencyBlock,
})
if err != nil {
fmt.Println(err.Error())
fmt.Println("Error parsing file", err.Error())
return files, err
}
// Add initial terragrunt.hcl file
files = append(files, path)
// Add all includes files
for _, i := range terragruntConfig.ProcessedIncludes {
if strings.HasPrefix(i.Path, ".") {
if strings.HasPrefix(i.Path, ".") || !strings.HasPrefix(i.Path, "/") {
// Convert relative path to absolute
files = append(files, filepath.Clean(filepath.Dir(path)+"/"+i.Path))
} else {
Expand Down

0 comments on commit 1f014d1

Please sign in to comment.