1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-20 20:42:20 -07:00

WTF-400 PagerDuty extracted to new config format

This commit is contained in:
Chris Cummer
2019-04-16 01:39:45 -07:00
parent 265149ca11
commit a8e9f69c22
4 changed files with 49 additions and 22 deletions

View File

@@ -0,0 +1,32 @@
package pagerduty
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
apiKey string
escalationFilter []interface{}
showIncidents bool
showSchedules bool
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
localConfig, _ := ymlConfig.Get("wtf.mods.pagerduty")
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
apiKey: localConfig.UString("apiKey", os.Getenv("WTF_PAGERDUTY_API_KEY")),
escalationFilter: localConfig.UList("escalationFilter"),
showIncidents: localConfig.UBool("showIncidents", true),
showSchedules: localConfig.UBool("showSchedules", true),
}
return &settings
}