Rename the config structs setDefaults to validate

This allows us to check for some required values and give an easy to respond
to error at startup rather than a lot of validation during run time.
This commit is contained in:
Gary Kramlich
2021-11-19 16:53:43 -06:00
parent 8553f49ac6
commit 2b63ddc6b8
5 changed files with 52 additions and 16 deletions

View File

@@ -13,12 +13,12 @@ type appservice struct {
HSToken string `yaml:"hs_token"`
}
func (a *appservice) setDefaults() error {
func (a *appservice) validate() error {
if a.ID == "" {
a.ID = "discord"
}
if err := a.Bot.setDefaults(); err != nil {
if err := a.Bot.validate(); err != nil {
return err
}
@@ -35,5 +35,5 @@ func (a *appservice) UnmarshalYAML(unmarshal func(interface{}) error) error {
*a = appservice(raw)
return a.setDefaults()
return a.validate()
}