Skip to content

Commit

Permalink
fix: Exit with error if argocd diff exits with failure (#39)
Browse files Browse the repository at this point in the history
In the previous implementation, only exit code for `argocd diff` 2 was
being treated as error.

In addition to error codes 0, 1, and 2, `argocd diff` also throws
additional errors, which were being processed as successful.
  • Loading branch information
pravindahal authored Oct 8, 2024
1 parent c9f97d6 commit 4ae25b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ func getArgoCDDiff(apps []ArgoCDApp) error {
"--local", app.Spec.Source.Path,
}
diff, err := sh.OutputWith(env, "argocd", append(cmdOptions, authOptions...)...)
if sh.ExitStatus(err) == 2 {

// `argocd diff` returns the following exit codes:
// - 2 on general errors,
// - 1 when a diff is found, and
// - 0 when no diff
// In addition, it also returns additional exit codes 11, 12, 13 and 20
errCode := sh.ExitStatus(err)
if errCode != 0 && errCode != 1 {
return err
}
fmt.Println("---- Diff of " + app.Metadata.Name + " ----")
Expand Down

0 comments on commit 4ae25b3

Please sign in to comment.