Skip to content

Commit bbe49ea

Browse files
authored
Help user to debug the diff error with temporary applications (#26)
* Keep the application if there is a diff error * Update the template
1 parent d4cf1aa commit bbe49ea

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

internal/pkg/argocd/argocd.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ func generateDiffOfAComponent(ctx context.Context, commentDiff bool, componentPa
521521
log.Debugf("Generating diff for component %s", componentPath)
522522
componentDiffResult.HasDiff, componentDiffResult.DiffElements, componentDiffResult.DiffError = generateArgocdAppDiff(ctx, commentDiff, app, detailedProject.Project, resources, argoSettings, diffOption)
523523

524-
if componentDiffResult.AppWasTemporarilyCreated {
524+
// only delete the temprorary app object if it was created and there was no error on diff
525+
// otherwise let's keep it for investigation
526+
if componentDiffResult.AppWasTemporarilyCreated && componentDiffResult.DiffError == nil {
525527
// Delete the temporary app object
526528
_, err = ac.app.Delete(ctx, &application.ApplicationDeleteRequest{Name: &app.Name, AppNamespace: &app.Namespace})
527529
if err != nil {

templates/argoCD-diff-pr-comment.gotmpl

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ Diff of ArgoCD applications:
44

55

66
{{if $appDiffResult.DiffError }}
7-
⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️
8-
```
7+
⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️
8+
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.
9+
{{- if $appDiffResult.AppWasTemporarilyCreated }}
10+
⚠️ For investigation we kept the temporary application, please make sure to clean it up later! ⚠️
11+
{{- end}}
12+
```
913
{{ $appDiffResult.DiffError }}
1014

1115
```

0 commit comments

Comments
 (0)