Skip to content

Commit

Permalink
fix bug from passing relative path and empty repoRoot to repo server (#…
Browse files Browse the repository at this point in the history
…242)

Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
  • Loading branch information
krancour authored Jan 30, 2024
1 parent 6f52850 commit 933ffd4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions internal/argocd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package argocd
import (
"context"
"encoding/json"
"path/filepath"

argoappv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
Expand Down Expand Up @@ -88,7 +89,8 @@ func (c ConfigManagementConfig) Expand(
}

func Render(
ctx context.Context, path string,
ctx context.Context,
repoRoot string,
cfg ConfigManagementConfig,
) ([]byte, error) {
src := argoappv1.ApplicationSource{
Expand All @@ -113,13 +115,9 @@ func Render(

res, err := repository.GenerateManifests(
ctx,
path,
// Seems ok for these next two arguments to be empty strings. If this is
// last mile rendering, we might be doing this in a directory outside of any
// repo. And event for regular rendering, we have already checked the
// revision we want.
"", // Repo root
"", // Revision
filepath.Join(repoRoot, cfg.Path),
repoRoot, // Repo root
"", // Revision -- seems ok to be empty string
&apiclient.ManifestRequest{
// Both of these fields need to be non-nil
Repo: &argoappv1.Repository{},
Expand Down
4 changes: 2 additions & 2 deletions rendering.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resources:
func (s *service) preRender(
ctx context.Context,
rc requestContext,
repoDir string,
repoRoot string,
) (map[string][]byte, error) {
logger := rc.logger
manifests := map[string][]byte{}
Expand All @@ -33,7 +33,7 @@ func (s *service) preRender(
appLogger := logger.WithField("app", appName)
manifests[appName], err = s.renderFn(
ctx,
filepath.Join(repoDir, appConfig.ConfigManagement.Path),
repoRoot,
appConfig.ConfigManagement,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type service struct {
logger *log.Logger
renderFn func(
ctx context.Context,
path string,
repoRoot string,
cfg argocd.ConfigManagementConfig,
) ([]byte, error)
}
Expand Down

0 comments on commit 933ffd4

Please sign in to comment.