github.com/wtfutil/wtf@v0.43.0/modules/uptimerobot/settings.go (about) 1 package uptimerobot 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 ) 9 10 const ( 11 defaultFocusable = true 12 defaultTitle = "Uptime Robot" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 apiKey string `help:"An UptimeRobot API key."` 19 uptimePeriods string `help:"The periods over which to display uptime (in days, dash-separated)." optional:"true"` 20 offlineFirst bool `help:"Display offline monitors at the top." optional:"true"` 21 } 22 23 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 24 25 settings := Settings{ 26 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 27 28 apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_UPTIMEROBOT_APIKEY")), 29 uptimePeriods: ymlConfig.UString("uptimePeriods", "30"), 30 offlineFirst: ymlConfig.UBool("offlineFirst", false), 31 } 32 33 cfg.ModuleSecret(name, globalConfig, &settings.apiKey). 34 Service("https://api.uptimerobot.com").Load() 35 36 return &settings 37 }