quick unhandled error fix for gosec
@@ -36,9 +36,9 @@ func main() {
if err != nil {
reportErr := fmt.Errorf("error occurred performing a " + http.MethodGet + " to " + checkURL + ": " + err.Error())
log.Errorln(reportErr.Error())
- err = kh.ReportFailure([]string{reportErr.Error()})
- if err != nil {
- log.Fatalln("error when reporting to kuberhealthy:", err.Error())
+ reportFailureErr = kh.ReportFailure([]string{reportErr.Error()})
+ if reportFailureErr != nil {
+ log.Fatalln("error when reporting to kuberhealthy:", reportFailureErr.Error())
}
os.Exit(0)
}
@@ -46,13 +46,19 @@ func main() {
// Check if the response status code is a 200.
if r.StatusCode == http.StatusOK {
log.Infoln("Got a", r.StatusCode, "with a", http.MethodGet, "to", checkURL)
- kh.ReportSuccess()
+ reportSuccessErr := kh.ReportSuccess()
+ if err != nil {
+ log.Fatalln("error when reporting to kuberhealthy:", reportSuccessErr.Error())
+ }
os.Exit(0)
}
reportErr := fmt.Errorf("unable to retrieve a " + strconv.Itoa(http.StatusOK) + " from " + checkURL + " got a " + strconv.Itoa(r.StatusCode) + " instead")
log.Errorln(reportErr.Error())
- kh.ReportFailure([]string{reportErr.Error()})
+ reportFailureErr := kh.ReportFailure([]string{reportErr.Error()})
+ if reportFailureErr != nil {
+ log.Fatalln("error when reporting to kuberhealthy:", reportFailureErr.Error())
+ }
os.Exit(0)
}
