Skip to content

Commit

Permalink
fix: pass refSources when calling GetAppDetails (#18962)
Browse files Browse the repository at this point in the history
* Get refSources when calling GetAppDetails

Signed-off-by: ishitasequeira <ishiseq29@gmail.com>

* fix lint errors

Signed-off-by: ishitasequeira <ishiseq29@gmail.com>

* fix unit tests

Signed-off-by: ishitasequeira <ishiseq29@gmail.com>

* fix unit tests

Signed-off-by: ishitasequeira <ishiseq29@gmail.com>

---------

Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
  • Loading branch information
ishitasequeira authored Jul 9, 2024
1 parent aa2837d commit 19e3c1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func TestHelmChartReferencingExternalValues_OutOfBounds_Symlink(t *testing.T) {
err = os.WriteFile("./testdata/oob-symlink/values.yaml", []byte("foo: bar"), 0o644)
require.NoError(t, err)
spec := argoappv1.ApplicationSpec{
Project: "default",
Sources: []argoappv1.ApplicationSource{
{RepoURL: "https://helm.example.com", Chart: "my-chart", TargetRevision: ">= 1.0.0", Helm: &argoappv1.ApplicationSourceHelm{
// Reference `ref` but do not use the oob symlink. The mere existence of the link should be enough to
Expand Down
10 changes: 10 additions & 0 deletions server/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,23 @@ func (s *Server) GetAppDetails(ctx context.Context, q *repositorypkg.RepoAppDeta
return nil, err
}

refSources := make(appsv1.RefTargetRevisionMapping)
if app != nil && app.Spec.HasMultipleSources() {
// Store the map of all sources having ref field into a map for applications with sources field
refSources, err = argo.GetRefSources(ctx, app.Spec.Sources, q.AppProject, s.db.GetRepository, []string{}, false)
if err != nil {
return nil, fmt.Errorf("failed to get ref sources: %w", err)
}
}

return repoClient.GetAppDetails(ctx, &apiclient.RepoServerAppDetailsQuery{
Repo: repo,
Source: q.Source,
Repos: helmRepos,
KustomizeOptions: kustomizeOptions,
HelmOptions: helmOptions,
AppName: q.AppName,
RefSources: refSources,
})
}

Expand Down
9 changes: 8 additions & 1 deletion util/helm/helm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package helm

import (
"errors"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -153,7 +154,13 @@ func (h *helm) GetParameters(valuesFiles []pathutil.ResolvedFilePath, appPath, r
if err == nil && (parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
fileValues, err = config.ReadRemoteFile(file)
} else {
if _, err := os.Stat(file); os.IsNotExist(err) {
_, fileReadErr := os.Stat(file)
if os.IsNotExist(fileReadErr) {
log.Debugf("File not found %s", file)
continue
}
if errors.Is(fileReadErr, os.ErrPermission) {
log.Debugf("File does not have permissions %s", file)
continue
}
fileValues, err = os.ReadFile(file)
Expand Down

0 comments on commit 19e3c1a

Please sign in to comment.