Skip to content

Commit

Permalink
add local modules to dependency (when_modified) list
Browse files Browse the repository at this point in the history
  • Loading branch information
wakeful committed Aug 1, 2023
1 parent c290fed commit 0d7b808
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/parser/pars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestParseDir(t *testing.T) {
"with-dep": {
"../../vpc",
"../sg",
"../src",
},
},
},
Expand Down
18 changes: 15 additions & 3 deletions pkg/terragrunt/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package terragrunt
import (
"fmt"
"sort"
"strings"

"github.com/gruntwork-io/terragrunt/config"
"github.com/gruntwork-io/terragrunt/options"
Expand All @@ -18,16 +19,27 @@ func GetDependencies(path string) ([]string, error) {
configFile, err := config.PartialParseConfigFile(path, terragruntOptions, nil, []config.PartialDecodeSectionType{
config.DependencyBlock,
config.DependenciesBlock,
config.TerraformSource,
})
if err != nil {
return nil, fmt.Errorf("%w", err)
}

if configFile.Dependencies == nil {
return nil, nil
var output []string

if configFile.Terraform != nil {
source := configFile.Terraform.Source
if source != nil && *source != "" {
if strings.HasPrefix(*source, "./") || strings.HasPrefix(*source, "../") {
output = append(output, *source)
}
}
}

if configFile.Dependencies != nil {
output = append(output, configFile.Dependencies.Paths...)
}

output := configFile.Dependencies.Paths
sort.Strings(output)

return output, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/terragrunt/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestGetDependencies(t *testing.T) {
name: "we should get a map of string slices",
path: "with-dep/terragrunt.hcl",
wantErr: false,
want: []string{"../../vpc", "../sg"},
want: []string{"../../vpc", "../sg", "../src"},
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 0d7b808

Please sign in to comment.