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 (
|
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user