Compare commits

..

2 Commits

Author SHA1 Message Date
amery 379794cedd zones: introduce (private) logger interface
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-07 13:57:18 +00:00
amery 24f5232ff6 zones: introduce WithLogger() scan option
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-07 13:57:18 +00:00
4 changed files with 5 additions and 10 deletions
-2
View File
@@ -10,8 +10,6 @@ import (
// A Machine is a machine on a Zone // A Machine is a machine on a Zone
type Machine struct { type Machine struct {
zone *Zone zone *Zone
logger
ID int `toml:"id"` ID int `toml:"id"`
Name string `toml:"-" json:"-" yaml:"-"` Name string `toml:"-" json:"-" yaml:"-"`
+1 -1
View File
@@ -22,7 +22,7 @@ type ScanOptions struct {
// Logger specifies the logger to be used. otherwise // Logger specifies the logger to be used. otherwise
// the scanner will be mute // the scanner will be mute
slog.Logger Logger slog.Logger
} }
// ResolvePublicAddresses instructs the scanner to use // ResolvePublicAddresses instructs the scanner to use
+4 -6
View File
@@ -32,9 +32,8 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
for _, e := range entries { for _, e := range entries {
if e.IsDir() { if e.IsDir() {
z := &Zone{ z := &Zone{
zones: m, zones: m,
logger: m, Name: e.Name(),
Name: e.Name(),
} }
if err := z.scan(); err != nil { if err := z.scan(); err != nil {
@@ -133,9 +132,8 @@ func (z *Zone) scan() error {
for _, e := range entries { for _, e := range entries {
if e.IsDir() { if e.IsDir() {
m := &Machine{ m := &Machine{
zone: z, zone: z,
logger: z, Name: e.Name(),
Name: e.Name(),
} }
if err := m.init(); err != nil { if err := m.init(); err != nil {
-1
View File
@@ -88,7 +88,6 @@ func FilterMachines(m MachineIterator, cond func(*Machine) bool) (Machines, int)
// Zone represents one zone in a cluster // Zone represents one zone in a cluster
type Zone struct { type Zone struct {
zones *Zones zones *Zones
logger
ID int `toml:"id"` ID int `toml:"id"`
Name string `toml:"name"` Name string `toml:"name"`