Browse Source

zones: introduce Zones.GetMachineByName()

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/1/head
Alejandro Mery 10 months ago
parent
commit
cb5ea80e66
  1. 18
      pkg/zones/zones.go

18
pkg/zones/zones.go

@ -53,6 +53,24 @@ func (m *Zones) ForEachZone(fn func(*Zone) bool) {
}
}
// GetMachineByName looks for a machine with the specified
// name on any zone
func (m *Zones) GetMachineByName(name string) (*Machine, bool) {
var out *Machine
if name != "" {
m.ForEachMachine(func(p *Machine) bool {
if p.Name == name {
out = p
}
return out != nil
})
}
return out, out != nil
}
// NewFS builds a [Zones] tree using the given directory
func NewFS(dir fs.FS, domain string) (*Zones, error) {
lockuper := resolver.NewCloudflareLookuper()

Loading…
Cancel
Save