Files
vuls/config/saasconf.go
hiroka-wada 9d8e510c0d add: json tag (#1746)
Co-authored-by: 和田皓翔 <wadahiroka@192.168.0.6>
2023-09-26 15:50:18 +09:00

35 lines
687 B
Go

package config
import (
"github.com/asaskevich/govalidator"
"golang.org/x/xerrors"
)
// SaasConf is FutureVuls config
type SaasConf struct {
GroupID int64 `json:"GroupID"`
Token string `json:"Token"`
URL string `json:"URL"`
}
// Validate validates configuration
func (c *SaasConf) Validate() (errs []error) {
if c.GroupID == 0 {
errs = append(errs, xerrors.New("GroupID must not be empty"))
}
if len(c.Token) == 0 {
errs = append(errs, xerrors.New("Token must not be empty"))
}
if len(c.URL) == 0 {
errs = append(errs, xerrors.New("URL must not be empty"))
}
_, err := govalidator.ValidateStruct(c)
if err != nil {
errs = append(errs, err)
}
return
}