zones: adds ForEachMachine() iterator

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-22 00:36:47 +00:00
parent 3599812072
commit be9da490ff
+9
View File
@@ -31,6 +31,15 @@ type Zones struct {
Zones []*Zone `toml:"zones"`
}
// ForEachMachine calls a function for each Machine in the cluster
func (m *Zones) ForEachMachine(fn func(*Machine)) {
for _, z := range m.Zones {
for _, p := range z.Machines {
fn(p)
}
}
}
// NewFS builds a [Zones] tree using the given directory
func NewFS(dir fs.FS, domain string) (*Zones, error) {
z := &Zones{