Skip to content

Commit 334bbdf

Browse files
committed
revert filterPaths modification
1 parent 1ca2067 commit 334bbdf

File tree

6 files changed

+12
-36
lines changed

6 files changed

+12
-36
lines changed

backend/controllers/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
376376
diggerYmlStr, ghService, config, projectsGraph, _, _, changedFiles, err := getDiggerConfigForPR(gh, organisationId, prLabelsStr, installationId, repoFullName, repoOwner, repoName, cloneURL, prNumber)
377377
if err != nil {
378378
log.Printf("getDiggerConfigForPR error: %v", err)
379+
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error loading digger config: %v", err))
379380
return fmt.Errorf("error getting digger config")
380381
}
381382

libs/digger_config/digger_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string,
299299
CreateProjectName: true,
300300
DefaultWorkflow: workflow,
301301
WorkflowFile: b.WorkflowFile,
302-
FilterPaths: []string{path.Join(terraformDir, *b.RootDir)},
302+
FilterPath: path.Join(terraformDir, *b.RootDir),
303303
AwsRoleToAssume: b.AwsRoleToAssume,
304304
AwsCognitoOidcConfig: b.AwsCognitoOidcConfig,
305305
}
@@ -522,7 +522,7 @@ func hydrateDiggerConfigYamlWithTerragrunt(configYaml *DiggerConfigYaml, parsing
522522
projectExternalChilds,
523523
parsingConfig.AutoMerge,
524524
parallel,
525-
parsingConfig.FilterPaths,
525+
parsingConfig.FilterPath,
526526
parsingConfig.CreateHclProjectChilds,
527527
ignoreParentTerragrunt,
528528
parsingConfig.IgnoreDependencyBlocks,

libs/digger_config/terragrunt/atlantis/generate.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ func createHclProject(defaultWorkflow string, defaultApplyRequirements []string,
598598
}
599599

600600
// Finds the absolute paths of all terragrunt.hcl files
601-
func getAllTerragruntFiles(filterPaths []string, projectHclFiles []string, path string) ([]string, error) {
601+
func getAllTerragruntFiles(filterPath string, projectHclFiles []string, path string) ([]string, error) {
602602
options, err := options.NewTerragruntOptionsWithConfigPath(path)
603603
if err != nil {
604604
return nil, err
@@ -610,15 +610,11 @@ func getAllTerragruntFiles(filterPaths []string, projectHclFiles []string, path
610610
workingPaths := []string{path}
611611

612612
// filters are not working (yet) if using project hcl files (which are kind of filters by themselves)
613-
if len(filterPaths) > 0 && len(projectHclFiles) == 0 {
614-
workingPaths = []string{}
615-
for _, filterPath := range filterPaths {
616-
// get all matching folders
617-
theseWorkingPaths, err := filepath.Glob(filterPath)
618-
if err != nil {
619-
return nil, err
620-
}
621-
workingPaths = append(workingPaths, theseWorkingPaths...)
613+
if filterPath != "" && len(projectHclFiles) == 0 {
614+
// get all matching folders
615+
workingPaths, err = filepath.Glob(filterPath)
616+
if err != nil {
617+
return nil, err
622618
}
623619
}
624620

@@ -682,7 +678,7 @@ func getAllTerragruntProjectHclFiles(projectHclFiles []string, gitRoot string) m
682678
return uniqueHclFileAbsPaths
683679
}
684680

685-
func Parse(gitRoot string, projectHclFiles []string, createHclProjectExternalChilds bool, autoMerge bool, parallel bool, filterPaths []string, createHclProjectChilds bool, ignoreParentTerragrunt bool, ignoreDependencyBlocks bool, cascadeDependencies bool, defaultWorkflow string, defaultApplyRequirements []string, autoPlan bool, defaultTerraformVersion string, createProjectName bool, createWorkspace bool, preserveProjects bool, useProjectMarkers bool, executionOrderGroups bool, triggerProjectsFromDirOnly bool) (*AtlantisConfig, map[string][]string, error) {
681+
func Parse(gitRoot string, projectHclFiles []string, createHclProjectExternalChilds bool, autoMerge bool, parallel bool, filterPath string, createHclProjectChilds bool, ignoreParentTerragrunt bool, ignoreDependencyBlocks bool, cascadeDependencies bool, defaultWorkflow string, defaultApplyRequirements []string, autoPlan bool, defaultTerraformVersion string, createProjectName bool, createWorkspace bool, preserveProjects bool, useProjectMarkers bool, executionOrderGroups bool, triggerProjectsFromDirOnly bool) (*AtlantisConfig, map[string][]string, error) {
686682
// Ensure the gitRoot has a trailing slash and is an absolute path
687683
absoluteGitRoot, err := filepath.Abs(gitRoot)
688684
if err != nil {
@@ -718,7 +714,7 @@ func Parse(gitRoot string, projectHclFiles []string, createHclProjectExternalChi
718714
sem := semaphore.NewWeighted(10)
719715
projectDependenciesMap := sync.Map{}
720716
for _, workingDir := range workingDirs {
721-
terragruntFiles, err := getAllTerragruntFiles(filterPaths, projectHclFiles, workingDir)
717+
terragruntFiles, err := getAllTerragruntFiles(filterPath, projectHclFiles, workingDir)
722718
if err != nil {
723719
return nil, nil, err
724720
}

libs/digger_config/utils.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66
"path"
77
"path/filepath"
8-
"strings"
98
)
109

1110
func GetPatternsRelativeToRepo(projectPath string, patterns []string) ([]string, error) {
@@ -16,16 +15,6 @@ func GetPatternsRelativeToRepo(projectPath string, patterns []string) ([]string,
1615
return res, nil
1716
}
1817

19-
func FilterPathsOutsideOfProjectPath(projectPath string, patterns []string) ([]string, error) {
20-
res := make([]string, 0)
21-
for _, pattern := range patterns {
22-
if strings.HasPrefix(pattern, projectPath) {
23-
res = append(res, pattern)
24-
}
25-
}
26-
return res, nil
27-
}
28-
2918
func NormalizeFileName(fileName string) string {
3019
res, err := filepath.Abs(path.Join("/", fileName))
3120
if err != nil {

libs/digger_config/utils_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,3 @@ func TestGetPatternsRelativeToRepo(t *testing.T) {
4545
assert.Equal(t, "myProject/terraform/environments/devel/*.hcl", res[0])
4646

4747
}
48-
49-
func TestFilterPathsOutsideOfProjectPath(t *testing.T) {
50-
projectDir := "staging/aws/us-east-1/k8s"
51-
includePatterns := []string{"staging/aws/us-east-1/k8s/*.hcl", "staging/terragrunt-root.hcl vpc/*.tf*", "staging/aws/us-east-1/aws_region.tfvars", "staging/aws/aws_assume_role_arn.tfvars", "staging/aws/us-east-1/k8s/*.tf*"}
52-
res, _ := FilterPathsOutsideOfProjectPath(projectDir, includePatterns)
53-
assert.Equal(t, 2, len(res))
54-
assert.Equal(t, "staging/aws/us-east-1/k8s/*.hcl", res[0])
55-
assert.Equal(t, "staging/aws/us-east-1/k8s/*.tf*", res[1])
56-
57-
}

libs/digger_config/yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type TerragruntParsingConfig struct {
149149
CreateProjectName bool `yaml:"createProjectName"`
150150
DefaultTerraformVersion string `yaml:"defaultTerraformVersion"`
151151
DefaultWorkflow string `yaml:"defaultWorkflow"`
152-
FilterPaths []string `yaml:"filterPath"`
152+
FilterPath string `yaml:"filterPath"`
153153
OutputPath string `yaml:"outputPath"`
154154
PreserveWorkflows *bool `yaml:"preserveWorkflows,omitempty"`
155155
PreserveProjects bool `yaml:"preserveProjects"`

0 commit comments

Comments
 (0)