Chatwork support (#634)

This commit is contained in:
adachin
2018-04-27 14:59:58 +09:00
committed by Kota Kanbe
parent 7a1644135a
commit 314f775243
5 changed files with 122 additions and 7 deletions

View File

@@ -94,13 +94,14 @@ type Config struct {
DebugSQL bool
Lang string
EMail SMTPConf
Slack SlackConf
Stride StrideConf
HipChat HipChatConf
Syslog SyslogConf
Default ServerInfo
Servers map[string]ServerInfo
EMail SMTPConf
Slack SlackConf
Stride StrideConf
HipChat HipChatConf
ChatWork ChatWorkConf
Syslog SyslogConf
Default ServerInfo
Servers map[string]ServerInfo
CvssScoreOver float64
IgnoreUnscoredCves bool
@@ -132,6 +133,7 @@ type Config struct {
ToSlack bool
ToStride bool
ToHipChat bool
ToChatWork bool
ToEmail bool
ToSyslog bool
ToLocalFile bool
@@ -279,6 +281,10 @@ func (c Config) ValidateOnReport() bool {
errs = append(errs, hipchaterrs...)
}
if chatworkerrs := c.ChatWork.Validate(); 0 < len(chatworkerrs) {
errs = append(errs, chatworkerrs...)
}
if strideerrs := c.Stride.Validate(); 0 < len(strideerrs) {
errs = append(errs, strideerrs...)
}
@@ -519,6 +525,32 @@ func (c *HipChatConf) Validate() (errs []error) {
return
}
// ChatWorkConf is ChatWork config
type ChatWorkConf struct {
ApiToken string `json:"ApiToken"`
Room string `json:"Room"`
}
// Validate validates configuration
func (c *ChatWorkConf) Validate() (errs []error) {
if !Conf.ToChatWork {
return
}
if len(c.Room) == 0 {
errs = append(errs, fmt.Errorf("chatworkcaht.room must not be empty"))
}
if len(c.ApiToken) == 0 {
errs = append(errs, fmt.Errorf("chatworkcaht.ApiToken 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