diff --git a/cmd/sonobuoy/app/status.go b/cmd/sonobuoy/app/status.go index 41faedfcb..68e0a770c 100644 --- a/cmd/sonobuoy/app/status.go +++ b/cmd/sonobuoy/app/status.go @@ -80,10 +80,21 @@ func getStatus(cmd *cobra.Command, args []string) { } else { err = printSummary(os.Stdout, status) } + if err != nil { errlog.LogError(err) os.Exit(1) } + os.Exit(exitCode(status)) +} + +func exitCode(status *aggregation.Status) int { + switch status.Status { + case aggregation.FailedStatus: + return 1 + default: + return 0 + } } func humanReadableStatus(str string) string {