Skip to content

Commit 39ee73d

Browse files
reposerver(repository): fixed repeated resources generation for ApplicationSourceTypeDirectory
1 parent ba5c91c commit 39ee73d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

changelog/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
### Features
2-
- feat(event-reporter): multisourced apps support improvements: reporting syncOperationRevisions, detecting correct resource sourceIdx, reporting correct git commit info
1+
### Updates
2+
- feat(event-reporter): multisourced apps support improvements: reporting syncOperationRevisions, detecting correct resource sourceIdx, reporting correct git commit info
3+
- fix(repo-server): fixed repeated resources generation for ApplicationSourceTypeDirectory

reposerver/repository/repository.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,21 +1812,18 @@ var manifestFile = regexp.MustCompile(`^.*\.(yaml|yml|json|jsonnet)$`)
18121812

18131813
// findManifests looks at all yaml files in a directory and unmarshals them into a list of unstructured objects
18141814
func findManifests(logCtx *log.Entry, appPath string, repoRoot string, env *v1alpha1.Env, directory v1alpha1.ApplicationSourceDirectory, enabledManifestGeneration map[string]bool, maxCombinedManifestQuantity resource.Quantity) ([]manifest, error) {
1815-
absRepoRoot, err := filepath.Abs(repoRoot)
1816-
if err != nil {
1817-
return nil, err
1818-
}
1819-
1820-
var manifests []manifest
1821-
18221815
// Validate the directory before loading any manifests to save memory.
18231816
potentiallyValidManifests, err := getPotentiallyValidManifests(logCtx, appPath, repoRoot, directory.Recurse, directory.Include, directory.Exclude, maxCombinedManifestQuantity)
18241817
if err != nil {
18251818
logCtx.Errorf("failed to get potentially valid manifests: %s", err)
18261819
return nil, fmt.Errorf("failed to get potentially valid manifests: %w", err)
18271820
}
18281821

1829-
var objs []*unstructured.Unstructured
1822+
absRepoRoot, err := filepath.Abs(repoRoot)
1823+
if err != nil {
1824+
return nil, err
1825+
}
1826+
var manifests []manifest
18301827
for _, potentiallyValidManifest := range potentiallyValidManifests {
18311828
manifestPath := potentiallyValidManifest.path
18321829
manifestFileInfo := potentiallyValidManifest.fileInfo
@@ -1836,6 +1833,7 @@ func findManifests(logCtx *log.Entry, appPath string, repoRoot string, env *v1al
18361833
repoRelPath, _ := filepath.Rel(absRepoRoot, absPath)
18371834

18381835
if strings.HasSuffix(manifestFileInfo.Name(), ".jsonnet") {
1836+
var objs []*unstructured.Unstructured
18391837
if !discovery.IsManifestGenerationEnabled(v1alpha1.ApplicationSourceTypeDirectory, enabledManifestGeneration) {
18401838
continue
18411839
}
@@ -1875,6 +1873,7 @@ func findManifests(logCtx *log.Entry, appPath string, repoRoot string, env *v1al
18751873
})
18761874
}
18771875
} else {
1876+
var objs []*unstructured.Unstructured
18781877
err := getObjsFromYAMLOrJson(logCtx, manifestPath, manifestFileInfo.Name(), &objs)
18791878
if err != nil {
18801879
return nil, err

0 commit comments

Comments
 (0)