Skip to content

Commit

Permalink
Use filepathx.Glob instead of filepath.Glob to support ** which match…
Browse files Browse the repository at this point in the history
…es one or more dirs
  • Loading branch information
kalapiotr committed Apr 18, 2023
1 parent 8b2463c commit 950d5ca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/gruntwork-io/terragrunt/config"
"github.com/gruntwork-io/terragrunt/options"
"github.com/spf13/cobra"
"github.com/yargevad/filepathx"

"golang.org/x/sync/errgroup"
"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -590,7 +591,7 @@ func getAllTerragruntFiles(path string) ([]string, error) {
// filters are not working (yet) if using project hcl files (which are kind of filters by themselves)
if filterPath != "" && len(projectHclFiles) == 0 {
// get all matching folders
workingPaths, err = filepath.Glob(filterPath)
workingPaths, err = filepathx.Glob(filterPath)
if err != nil {
return nil, err
}
Expand Down
9 changes: 9 additions & 0 deletions cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,15 @@ func TestFilterGlobFlagWithInfraLiveMySql(t *testing.T) {
})
}

func TestFilterGlobFlagWithInfraLiveMySqlDoubleWildcard(t *testing.T) {
runTest(t, filepath.Join("golden", "filterGlobInfraLiveMySQL.yaml"), []string{
"--root",
filepath.Join("..", "test_examples", "terragrunt-infrastructure-live-example"),
"--filter",
filepath.Join("..", "test_examples", "terragrunt-infrastructure-live-example", "**", "mysql"),
})
}

func TestMultipleIncludes(t *testing.T) {
runTest(t, filepath.Join("golden", "multiple_includes.yaml"), []string{
"--root",
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.16

require (
github.com/bmatcuk/doublestar v1.3.1 // indirect
github.com/debber/debber-v0.3 v0.0.0-20201001103732-e53137b65bb8 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-errors/errors v1.1.1 // indirect
github.com/gruntwork-io/terragrunt v0.36.6
Expand All @@ -12,11 +13,14 @@ require (
github.com/hashicorp/terraform-config-inspect v0.0.0-20210625153042-09f34846faab
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f // indirect
github.com/laher/goxc v0.18.1 // indirect
github.com/mattn/go-zglob v0.0.2 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.4 // indirect
github.com/yargevad/filepathx v1.0.0 // indirect
github.com/zclconf/go-cty v1.8.3
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/ini.v1 v1.57.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/debber/debber-v0.3 v0.0.0-20201001103732-e53137b65bb8 h1:a2HUpEk5VTewSv3bJ2oNNLJS5r9lyjhmHRkVbmK7vxo=
github.com/debber/debber-v0.3 v0.0.0-20201001103732-e53137b65bb8/go.mod h1:TCVRstzD4Q5cPZofOCFtaeBwCr5WXJdG3hxzFmYYnZ0=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
Expand Down Expand Up @@ -650,6 +652,10 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f h1:fQ8JwxJN77cxE0foUmSHkKQebcxyd6vAfWCv7Bs5r34=
github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f/go.mod h1:Ymqfd31XvifvQ001Ty97DbYjQoeJPnb1WVkFhGeNYA4=
github.com/laher/goxc v0.18.1 h1:b5KJsjerACeEBsFWBveVzdUjc5wetTA5IQhOSjFJx50=
github.com/laher/goxc v0.18.1/go.mod h1:NdnX1aggrtsAowOUacIAYkuGKn2Md8Ej2DpoPUUqofs=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
Expand Down Expand Up @@ -894,6 +900,8 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc=
github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down

0 comments on commit 950d5ca

Please sign in to comment.