1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/pagerduty/settings.go
2019-05-12 09:52:48 -07:00

36 lines
887 B
Go

package pagerduty
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const defaultTitle = "PagerDuty"
type Settings struct {
common *cfg.Common
apiKey string
escalationFilter []interface{}
scheduleIDs []interface{}
showIncidents bool
showSchedules bool
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_PAGERDUTY_API_KEY")),
escalationFilter: ymlConfig.UList("escalationFilter"),
scheduleIDs: ymlConfig.UList("scheduleIDs", []interface{}{}),
showIncidents: ymlConfig.UBool("showIncidents", true),
showSchedules: ymlConfig.UBool("showSchedules", true),
}
return &settings
}