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. 27
      pkg/zones/scan.go

27
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,21 +33,30 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
for _, e := range entries { for _, e := range entries {
if e.IsDir() { if e.IsDir() {
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)
}
}
}
return nil
}
func (m *Zones) newZone(name string) (*Zone, error) {
z := &Zone{ z := &Zone{
zones: m, zones: m,
logger: m, logger: m,
Name: e.Name(), Name: name,
} }
if err := z.scan(); err != nil { if err := z.scan(); err != nil {
return err return nil, err
} }
return z, nil
m.Zones = append(m.Zones, z)
}
}
return nil
} }
func (m *Zones) scanMachines(opts *ScanOptions) error { func (m *Zones) scanMachines(opts *ScanOptions) error {

Loading…
Cancel
Save