|
|
|
@ -3,6 +3,8 @@ package zones
|
|
|
|
|
import ( |
|
|
|
|
"io/fs" |
|
|
|
|
"sort" |
|
|
|
|
|
|
|
|
|
"darvaza.org/core" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func (m *Zones) scan(opts *ScanOptions) error { |
|
|
|
@ -31,22 +33,31 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
|
|
|
|
|
|
|
|
|
|
for _, e := range entries { |
|
|
|
|
if e.IsDir() { |
|
|
|
|
z := &Zone{ |
|
|
|
|
zones: 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, |
|
|
|
|
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 { |
|
|
|
|