package config import "fmt" type Host struct { Zone string `yaml:"zone"` Interface string `yaml:"interface"` Addresses []string `yaml:"addresses"` Options []string `yaml:"options,omitempty"` } func (c *Config) validateHosts() error { for i, h := range c.Hosts { if h.Zone == "" { return fmt.Errorf("host[%d]: zone required", i) } if _, ok := c.Zones[h.Zone]; !ok { return fmt.Errorf("host[%d]: zone %q not defined", i, h.Zone) } if h.Interface == "" { return fmt.Errorf("host[%d]: interface required", i) } if len(h.Addresses) == 0 { return fmt.Errorf("host[%d]: at least one address required", i) } } return nil }