github.com/wtfutil/wtf@v0.43.0/modules/datadog/settings.go (about) 1 package datadog 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 = "DataDog" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 apiKey string `help:"Your Datadog API key."` 19 applicationKey string `help:"Your Datadog Application key."` 20 tags []interface{} `help:"Array of tags you want to query monitors by."` 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", ymlConfig.UString("apikey", os.Getenv("WTF_DATADOG_API_KEY"))), 29 applicationKey: ymlConfig.UString("applicationKey", os.Getenv("WTF_DATADOG_APPLICATION_KEY")), 30 tags: ymlConfig.UList("monitors.tags"), 31 } 32 33 cfg.ModuleSecret(name+"-api", globalConfig, &settings.apiKey).Load() 34 cfg.ModuleSecret(name+"-app", globalConfig, &settings.applicationKey).Load() 35 36 return &settings 37 }