Browse Source

zones: ignore machine-less zones

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/11/head
Alejandro Mery 1 year ago
parent
commit
90dd0c1239
  1. 31
      pkg/zones/scan.go

31
pkg/zones/scan.go

@ -3,6 +3,8 @@ package zones
import ( import (
"io/fs" "io/fs"
"sort" "sort"
"darvaza.org/core"
) )
func (m *Zones) scan(opts *ScanOptions) error { func (m *Zones) scan(opts *ScanOptions) error {
@ -31,23 +33,32 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
for _, e := range entries { for _, e := range entries {
if e.IsDir() { if e.IsDir() {
z := &Zone{ z, err := m.newZone(e.Name())
zones: m, switch {
logger: m, case err != nil:
Name: e.Name(), 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 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 { func (m *Zones) scanMachines(opts *ScanOptions) error {
var err error var err error
m.ForEachMachine(func(p *Machine) bool { m.ForEachMachine(func(p *Machine) bool {

Loading…
Cancel
Save