diff --git a/internal/argocd/render.go b/internal/argocd/render.go index 67cb349..a5a736c 100644 --- a/internal/argocd/render.go +++ b/internal/argocd/render.go @@ -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" @@ -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{ @@ -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{}, diff --git a/rendering.go b/rendering.go index 82624b4..b736b6a 100644 --- a/rendering.go +++ b/rendering.go @@ -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{} @@ -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 { diff --git a/service.go b/service.go index c188c8f..e2907fd 100644 --- a/service.go +++ b/service.go @@ -30,7 +30,7 @@ type service struct { logger *log.Logger renderFn func( ctx context.Context, - path string, + repoRoot string, cfg argocd.ConfigManagementConfig, ) ([]byte, error) }