github.com/wtfutil/wtf@v0.43.0/modules/updown/settings.go (about) 1 package updown 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 = "Updown.io" 14 ) 15 16 type Settings struct { 17 *cfg.Common 18 19 apiKey string `help:"An Updown API key." optional:"false"` 20 tokens []string `help:"Filters the checks and returns only the checks with the specified tokens"` 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_UPDOWN_APIKEY")), 29 tokens: utils.ToStrs(ymlConfig.UList("tokens")), 30 } 31 32 cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load() 33 34 return &settings 35 }