1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/healthchecks/settings.go
Fredrik Steen 2341446376 Healthcecks module
Healthchecks.io is a service for monitoring cron jobs and similar
periodic processes.

Hosted: https://healthchecks.io/
API-Doc: https://healthchecks.io/docs/api/
GitHub: https://github.com/healthchecks/healthchecks

This module can be used both with hosted and self-hosted healthchecks.
2021-01-16 12:33:15 -08:00

39 lines
1.0 KiB
Go

package healthchecks
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils"
)
const (
defaultFocusable = true
defaultTitle = "Healthchecks.io"
)
type Settings struct {
*cfg.Common
apiKey string `help:"An healthchecks API key." optional:"false"`
apiURL string `help:"Base URL for API" optional:"true"`
tags []string `help:"Filters the checks and returns only the checks that are tagged with the specified value"`
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_HEALTHCHECKS_APIKEY")),
apiURL: ymlConfig.UString("apiURL", "https://hc-ping.com/"),
tags: utils.ToStrs(ymlConfig.UList("tags")),
}
cfg.ModuleSecret(name, globalConfig, &settings.apiKey).
Service("https://hc-ping.com/").Load()
return &settings
}