Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config/config.go
- @@ -96,6 +96,7 @@ type Config struct {
- EMail SMTPConf
- Slack SlackConf
- // config追加
- + HipChat HipChatConf
- Syslog SyslogConf
- Default ServerInfo
- Servers map[string]ServerInfo
- @@ -263,6 +264,10 @@ func (c Config) ValidateOnReport() bool {
- errs = append(errs, slackerrs...)
- }
- // 確かconfig validate的なコマンドがあって、hipchatのconfig validateも呼ぶように追加
- // そんなコマンドはないかも。ただ-to-hipchatオプションを付けたのにhipchatの設定がない場合
- // エラーが出ると思うので、そのへんの処理。
- + 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
- }
- // tomlのhip chat configを受け取る構造体
- +// HipChatConf is HipChat config
- +type HipChatConf struct {
- + AuthToken string `json:"AuthToken"`
- + Room string `json:"Room"`
- +}
- +
- // configのvalidate処理
- +// 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
Add Comment
Please, Sign In to add comment