Skip to content

Commit

Permalink
CR-25949: reposerver(repository): fixed repeated resources generation…
Browse files Browse the repository at this point in the history
… for ApplicationSourceTypeDirectory
  • Loading branch information
oleksandr-codefresh committed Nov 13, 2024
1 parent ba5c91c commit b348e9a
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Features
- feat(event-reporter): multisourced apps support improvements: reporting syncOperationRevisions, detecting correct resource sourceIdx, reporting correct git commit info
### Updates
- feat(event-reporter): multisourced apps support improvements: reporting syncOperationRevisions, detecting correct resource sourceIdx, reporting correct git commit info
- fix(repo-server): fixed repeated resources generation for ApplicationSourceTypeDirectory
15 changes: 7 additions & 8 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
@@ -1812,21 +1812,18 @@ var manifestFile = regexp.MustCompile(`^.*\.(yaml|yml|json|jsonnet)$`)

// findManifests looks at all yaml files in a directory and unmarshals them into a list of unstructured objects
func findManifests(logCtx *log.Entry, appPath string, repoRoot string, env *v1alpha1.Env, directory v1alpha1.ApplicationSourceDirectory, enabledManifestGeneration map[string]bool, maxCombinedManifestQuantity resource.Quantity) ([]manifest, error) {
absRepoRoot, err := filepath.Abs(repoRoot)
if err != nil {
return nil, err
}

var manifests []manifest

// Validate the directory before loading any manifests to save memory.
potentiallyValidManifests, err := getPotentiallyValidManifests(logCtx, appPath, repoRoot, directory.Recurse, directory.Include, directory.Exclude, maxCombinedManifestQuantity)
if err != nil {
logCtx.Errorf("failed to get potentially valid manifests: %s", err)
return nil, fmt.Errorf("failed to get potentially valid manifests: %w", err)
}

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

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

0 comments on commit b348e9a

Please sign in to comment.