hipchat support (#593)

* first commit

* hipchat conf

* hipchat conf
This commit is contained in:
kazuminn
2018-03-06 17:40:21 +09:00
committed by Kota Kanbe
parent 092a19bdc1
commit 26418be937
5 changed files with 108 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ type Config struct {
EMail SMTPConf
Slack SlackConf
HipChat HipChatConf
Syslog SyslogConf
Default ServerInfo
Servers map[string]ServerInfo
@@ -263,6 +264,10 @@ func (c Config) ValidateOnReport() bool {
errs = append(errs, slackerrs...)
}
if hipchaterrs := c.HipChat.Validate(); 0 < len(hipchaterrs) {
errs = append(errs, hipchaterrs...)
}
if syslogerrs := c.Syslog.Validate(); 0 < len(syslogerrs) {
errs = append(errs, syslogerrs...)
}
@@ -451,6 +456,30 @@ func (c *SlackConf) Validate() (errs []error) {
return
}
// HipChatConf is HipChat config
type HipChatConf struct {
AuthToken string `json:"AuthToken"`
Room string `json:"Room"`
}
// Validate validates configuration
func (c *HipChatConf) Validate() (errs []error) {
if len(c.Room) == 0 {
errs = append(errs, fmt.Errorf("room must not be empty"))
}
if len(c.AuthToken) == 0 {
errs = append(errs, fmt.Errorf("AuthToken must not be empty"))
}
_, err := valid.ValidateStruct(c)
if err != nil {
errs = append(errs, err)
}
return
}
// SyslogConf is syslog config
type SyslogConf struct {
Protocol string