github.com/wtfutil/wtf@v0.43.0/modules/healthchecks/settings.go (about) 1 package healthchecks 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 "github.com/wtfutil/wtf/utils" 9 ) 10 11 const ( 12 defaultFocusable = true 13 defaultTitle = "Healthchecks.io" 14 ) 15 16 type Settings struct { 17 *cfg.Common 18 19 apiKey string `help:"An healthchecks API key." optional:"false"` 20 apiURL string `help:"Base URL for API" optional:"true"` 21 tags []string `help:"Filters the checks and returns only the checks that are tagged with the specified value"` 22 } 23 24 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 25 26 settings := Settings{ 27 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 28 29 apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_HEALTHCHECKS_APIKEY")), 30 apiURL: ymlConfig.UString("apiURL", "https://hc-ping.com/"), 31 tags: utils.ToStrs(ymlConfig.UList("tags")), 32 } 33 34 cfg.ModuleSecret(name, globalConfig, &settings.apiKey). 35 Service(settings.apiURL).Load() 36 37 return &settings 38 }