go-healthchecks/cmd/success.go

31 lines
607 B
Go
Raw Permalink Normal View History

2024-10-02 13:26:14 +00:00
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)
}