30 lines
607 B
Go
30 lines
607 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
gohealthchecks "git.faercol.me/faercol/go-healthchecks"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var successCmd = &cobra.Command{
|
|
Use: "success",
|
|
Short: "Signal the check has successfully completed",
|
|
Long: ``,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
check := parseCheckFlags()
|
|
clt := gohealthchecks.NewPingClient(pingHost)
|
|
err := clt.ReportSuccess(cmd.Context(), check)
|
|
if err != nil {
|
|
failf("Failed to notify success: %s\n", err)
|
|
} else {
|
|
fmt.Println("Notified check success")
|
|
os.Exit(0)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(successCmd)
|
|
}
|