func getKuberhealthyRunUUID() (string, error) {
	khRunUUID := os.Getenv(external.KHRunUUID)
	if len(khRunUUID) < 1 {
		writeLog("ERROR: kuberhealthy run UUID from environment variable", external.KHRunUUID, "was blank")
		return "", fmt.Errorf("fetched %s environment variable but it was blank", external.KHRunUUID)
	}
	return khRunUUID, nil
}
getKuberhealthyRunUUID fetches the kuberheathy checker pod run UUID to send to our external checker
status to report to from the environment variable
package checkclient
import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"strconv"
	"time"
	"github.com/cenkalti/backoff"
	"github.com/kuberhealthy/kuberhealthy/v2/pkg/checks/external"
	"github.com/kuberhealthy/kuberhealthy/v2/pkg/checks/external/status"
)
var (
	Debug bool
)
const maxElapsedTime = time.Second * 30
func ReportSuccess() error {
	writeLog("DEBUG: Reporting SUCCESS")
	newReport := status.NewReport([]string{})
	return sendReport(newReport)
}
func ReportFailure(errorMessages []string) error {
	writeLog("DEBUG: Reporting FAILURE")
	newReport := status.NewReport(errorMessages)
	return sendReport(newReport)
}
func writeLog(i ...interface{}) {
	if Debug {
		log.Println("checkClient:", fmt.Sprint(i...))
	}
}
func sendReport(s status.Report) error {
	writeLog("DEBUG: Sending report with error length of:", len(s.Errors))
	writeLog("DEBUG: Sending report with ok state of:", s.OK)
	b, err := json.Marshal(s)
	if err != nil {
		writeLog("ERROR: Failed to marshal status JSON:", err)
		return fmt.Errorf("error mashaling status report json: %w", err)
	}
	url, err := getKuberhealthyURL()
	if err != nil {
		return fmt.Errorf("failed to fetch the kuberhealthy url: %w", err)
	}
	writeLog("INFO: Using kuberhealthy reporting URL: ", url)
	uuid, err := getKuberhealthyRunUUID()
	if err != nil {
		return fmt.Errorf("failed to fetch the kuberhealthy run uuid: %w", err)
	}
	writeLog("INFO: Using kuberhealthy run UUID: ", uuid)
	req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(b))
	if err != nil {
		return fmt.Errorf("error creating http request: %w", err)
	}
	req.Header.Set("kh-run-uuid", uuid)
	req.Header.Set("Content-Type", "application/json")
	exponentialBackOff := backoff.NewExponentialBackOff()
	exponentialBackOff.MaxElapsedTime = maxElapsedTime
	client := &http.Client{}
	var resp *http.Response
	err = backoff.Retry(func() error {
		var err error
		writeLog("DEBUG: Making POST request to kuberhealthy:")
		resp, err = client.Do(req)
		if err != nil {
			return err
		}
		if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusBadRequest) {
			writeLog("ERROR: got a bad status code from kuberhealthy:", resp.StatusCode, resp.Status)
			return fmt.Errorf("bad status code from kuberhealthy status reporting url: [%d] %s ", resp.StatusCode, resp.Status)
		}
		return nil
	}, exponentialBackOff)
	if err != nil {
		writeLog("ERROR: got an error sending POST to kuberhealthy:", err)
		return fmt.Errorf("bad POST request to kuberhealthy status reporting url: %w", err)
	}
	writeLog("INFO: Got a good http return status code from kuberhealthy URL:", url)
	return err
}
func getKuberhealthyURL() (string, error) {
	reportingURL := os.Getenv(external.KHReportingURL)
	if len(reportingURL) < 1 {
		writeLog("ERROR: kuberhealthy reporting URL from environment variable", external.KHReportingURL, "was blank")
		return "", fmt.Errorf("fetched %s environment variable but it was blank", external.KHReportingURL)
	}
	return reportingURL, nil
}