cluster: load regions when scanning a directory

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-10-29 15:56:47 +00:00
parent 935e69b0e9
commit ce7eac8e58
2 changed files with 119 additions and 26 deletions
+32
View File
@@ -106,6 +106,38 @@ func (m *Cluster) setRegionZones(name string, zones ...*Zone) {
})
}
func (m *Cluster) appendRegionRegions(name string, subs ...string) {
for i := range m.Regions {
r := &m.Regions[i]
if name == r.Name {
// found
r.Regions = append(r.Regions, subs...)
return
}
}
// new
m.Regions = append(m.Regions, Region{
Name: name,
Regions: subs,
})
}
func (z *Zone) appendRegions(regions ...string) error {
for _, s := range regions {
// TODO: validate
z.debug().
WithField("zone", z.Name).
WithField("region", s).
Print("attached")
z.Regions = append(z.Regions, s)
}
return nil
}
func (m *Cluster) finishRegion(r *Region) {
if r.m != nil {
// ready