mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-11 19:18:46 +00:00
32 lines
580 B
Go
32 lines
580 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type Toplevel struct {
|
|
Bind Bind `hcl:"bind,block"`
|
|
Domains []Domain `hcl:"domain,block"`
|
|
}
|
|
|
|
func (t *Toplevel) Valid() error {
|
|
var errs []error
|
|
|
|
if err := t.Bind.Valid(); err != nil {
|
|
errs = append(errs, fmt.Errorf("invalid bind block:\n%w", err))
|
|
}
|
|
|
|
for _, d := range t.Domains {
|
|
if err := d.Valid(); err != nil {
|
|
errs = append(errs, fmt.Errorf("when parsing domain %s: %w", d.Name, err))
|
|
}
|
|
}
|
|
|
|
if len(errs) != 0 {
|
|
return fmt.Errorf("invalid configuration file:\n%w", errors.Join(errs...))
|
|
}
|
|
|
|
return nil
|
|
}
|