zones: ignore machine-less zones
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
+21
-10
@@ -3,6 +3,8 @@ package zones
|
||||
import (
|
||||
"io/fs"
|
||||
"sort"
|
||||
|
||||
"darvaza.org/core"
|
||||
)
|
||||
|
||||
func (m *Zones) scan(opts *ScanOptions) error {
|
||||
@@ -31,23 +33,32 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
|
||||
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
z := &Zone{
|
||||
zones: m,
|
||||
logger: m,
|
||||
Name: e.Name(),
|
||||
z, err := m.newZone(e.Name())
|
||||
switch {
|
||||
case err != nil:
|
||||
return core.Wrap(err, e.Name())
|
||||
case z.Machines.Len() > 0:
|
||||
m.Zones = append(m.Zones, z)
|
||||
}
|
||||
|
||||
if err := z.scan(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Zones = append(m.Zones, z)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Zones) newZone(name string) (*Zone, error) {
|
||||
z := &Zone{
|
||||
zones: m,
|
||||
logger: m,
|
||||
Name: name,
|
||||
}
|
||||
|
||||
if err := z.scan(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return z, nil
|
||||
}
|
||||
|
||||
func (m *Zones) scanMachines(opts *ScanOptions) error {
|
||||
var err error
|
||||
m.ForEachMachine(func(p *Machine) bool {
|
||||
|
||||
Reference in New Issue
Block a user