zones: add resolver and domain
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
+11
-5
@@ -4,6 +4,8 @@ package zones
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
|
||||
"darvaza.org/resolver"
|
||||
)
|
||||
|
||||
// Zone represents one zone in a cluster
|
||||
@@ -22,15 +24,19 @@ func (z *Zone) String() string {
|
||||
|
||||
// Zones represents all zones in a cluster
|
||||
type Zones struct {
|
||||
dir fs.FS
|
||||
dir fs.FS
|
||||
resolver resolver.Resolver
|
||||
domain string
|
||||
|
||||
Zones []*Zone `toml:"zones"`
|
||||
}
|
||||
|
||||
// NewFS builds a [Zones] tree using the given directory
|
||||
func NewFS(dir fs.FS) (*Zones, error) {
|
||||
func NewFS(dir fs.FS, domain string) (*Zones, error) {
|
||||
z := &Zones{
|
||||
dir: dir,
|
||||
dir: dir,
|
||||
resolver: resolver.SystemResolver(true),
|
||||
domain: domain,
|
||||
}
|
||||
|
||||
if err := z.scan(); err != nil {
|
||||
@@ -41,6 +47,6 @@ func NewFS(dir fs.FS) (*Zones, error) {
|
||||
}
|
||||
|
||||
// New builds a [Zones] tree using the given directory
|
||||
func New(dir string) (*Zones, error) {
|
||||
return NewFS(os.DirFS(dir))
|
||||
func New(dir, domain string) (*Zones, error) {
|
||||
return NewFS(os.DirFS(dir), domain)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user