* refactor config * fix saas config * feat(config): scanmodule for each server in config.toml * feat(config): enable to specify containersOnly in config.toml * add new keys of config.toml to discover.go * fix summary output, logging
33 lines
640 B
Go
33 lines
640 B
Go
package config
|
|
|
|
import (
|
|
"github.com/asaskevich/govalidator"
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
// ChatWorkConf is ChatWork config
|
|
type ChatWorkConf struct {
|
|
APIToken string `json:"-"`
|
|
Room string `json:"-"`
|
|
}
|
|
|
|
// Validate validates configuration
|
|
func (c *ChatWorkConf) Validate() (errs []error) {
|
|
if !Conf.ToChatWork {
|
|
return
|
|
}
|
|
if len(c.Room) == 0 {
|
|
errs = append(errs, xerrors.New("chatWorkConf.room must not be empty"))
|
|
}
|
|
|
|
if len(c.APIToken) == 0 {
|
|
errs = append(errs, xerrors.New("chatWorkConf.ApiToken must not be empty"))
|
|
}
|
|
|
|
_, err := govalidator.ValidateStruct(c)
|
|
if err != nil {
|
|
errs = append(errs, err)
|
|
}
|
|
return
|
|
}
|