Skip to content

Commit

Permalink
Help user to debug the diff error with temporary applications (#26)
Browse files Browse the repository at this point in the history
* Keep the application if there is a diff error

* Update the template
  • Loading branch information
yzdann authored Sep 9, 2024
1 parent d4cf1aa commit bbe49ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ func generateDiffOfAComponent(ctx context.Context, commentDiff bool, componentPa
log.Debugf("Generating diff for component %s", componentPath)
componentDiffResult.HasDiff, componentDiffResult.DiffElements, componentDiffResult.DiffError = generateArgocdAppDiff(ctx, commentDiff, app, detailedProject.Project, resources, argoSettings, diffOption)

if componentDiffResult.AppWasTemporarilyCreated {
// only delete the temprorary app object if it was created and there was no error on diff
// otherwise let's keep it for investigation
if componentDiffResult.AppWasTemporarilyCreated && componentDiffResult.DiffError == nil {
// Delete the temporary app object
_, err = ac.app.Delete(ctx, &application.ApplicationDeleteRequest{Name: &app.Name, AppNamespace: &app.Namespace})
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions templates/argoCD-diff-pr-comment.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Diff of ArgoCD applications:


{{if $appDiffResult.DiffError }}
⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️
```
⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️
Please check the App Conditions of <img src="https://argo-cd.readthedocs.io/en/stable/assets/favicon.png" width="20"/> **[{{ $appDiffResult.ArgoCdAppName }}]({{ $appDiffResult.ArgoCdAppURL }})** for more details.
{{- if $appDiffResult.AppWasTemporarilyCreated }}
⚠️ For investigation we kept the temporary application, please make sure to clean it up later! ⚠️
{{- end}}
```
{{ $appDiffResult.DiffError }}

```
Expand Down

0 comments on commit bbe49ea

Please sign in to comment.