40 lines
797 B
Go
40 lines
797 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
gohealthchecks "git.faercol.me/faercol/go-healthchecks"
|
|
)
|
|
|
|
func mustParseUUIDCheck(checkID, runID string) gohealthchecks.Check {
|
|
check, err := gohealthchecks.NewUUIDCheck(checkID, runID)
|
|
if err != nil {
|
|
failf("Invalid UUID: %s\n", err)
|
|
}
|
|
return check
|
|
}
|
|
|
|
func parseCheckFlags() gohealthchecks.Check {
|
|
var check gohealthchecks.Check
|
|
var err error
|
|
if checkUUID != "" {
|
|
check = mustParseUUIDCheck(checkUUID, runID)
|
|
} else {
|
|
check, err = gohealthchecks.NewSlugCheck(pingKey, checkSlug, autoCreate, runID)
|
|
if err != nil {
|
|
failf("Invalid UUID: %s\n", err)
|
|
}
|
|
}
|
|
return check
|
|
}
|
|
|
|
func failf(format string, args ...any) {
|
|
fmt.Fprintf(os.Stderr, format, args...)
|
|
os.Exit(1)
|
|
}
|
|
|
|
func failln(msg string) {
|
|
fmt.Fprintln(os.Stderr, msg)
|
|
os.Exit(1)
|
|
}
|