zones: introduce Zones.GetMachineByName()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-22 20:17:34 +00:00
parent f7da9519fa
commit cb5ea80e66
+18
View File
@@ -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()