package main import ( "fmt" "os" gohealthchecks "git.faercol.me/faercol/go-healthchecks" "github.com/spf13/cobra" ) var failureCmd = &cobra.Command{ Use: "failure", Short: "Signal the check has failed", Long: ``, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { check := parseCheckFlags() msg := "" if len(args) > 0 { msg = args[0] } clt := gohealthchecks.NewPingClient(pingHost) err := clt.ReportFailure(cmd.Context(), check, msg) if err != nil { failf("Failed to notify failure: %s\n", err) } else { fmt.Println("Notified check failure") os.Exit(0) } }, } func init() { rootCmd.AddCommand(failureCmd) }