From 1abcc862fe85f5a49cff41a3bd0ed891908dfca4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 4 Dec 2024 02:25:46 -0600 Subject: [PATCH] code is better because of autogenpb --- http.go | 6 +++--- machine.go | 8 ++++---- watchdog.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/http.go b/http.go index b0a9f8c..47ec2b5 100644 --- a/http.go +++ b/http.go @@ -77,10 +77,10 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if route == "/list" { log.HttpMode(w) defer log.HttpMode(nil) - loop := me.machines.SortByName() + loop := me.machines.SortByHostname() for loop.Scan() { - m := loop.Machine() - zood := m.FindPackageByName("zood") + m := loop.Next() + zood := m.Packages.FindByName("zood") v := me.targets["zood"] // this is the target version if zood == nil { log.Info("machine", m.Hostname, "does not have zood installed") diff --git a/machine.go b/machine.go index ed8a019..6b1a8ea 100644 --- a/machine.go +++ b/machine.go @@ -11,7 +11,7 @@ func updateMachine(u *zoopb.Machine) string { if u == nil { return "nil" } - m := me.machines.FindByName(u.Hostname) + m := me.machines.FindByHostname(u.Hostname) if m == nil { log.Info("adding new machine", u.Hostname) me.machines.Append(u) @@ -38,7 +38,7 @@ func updateMachine(u *zoopb.Machine) string { if u.Packages == nil { u.Packages = new(zoopb.Packages) } - if zood := m.FindPackageByName("zood"); zood != nil { + if zood := m.Packages.FindByName("zood"); zood != nil { log.Log(INFO, m.Hostname, "has zood version", zood.Version) } @@ -55,9 +55,9 @@ func updatePackages(m *zoopb.Machine, newp *zoopb.Packages) bool { loop := newp.SortByName() for loop.Scan() { - p := loop.Package() + p := loop.Next() if p.Name == "zood" { - if pold := m.FindPackageByName("zood"); pold == nil { + if pold := m.Packages.FindByName("zood"); pold == nil { changed = true log.Log(ZOOD, "updatePackages() new package", p.Name , "version", p.Version, "machine", m.Hostname) m.Packages.Append(p) diff --git a/watchdog.go b/watchdog.go index 0609bb3..9cce396 100644 --- a/watchdog.go +++ b/watchdog.go @@ -41,11 +41,11 @@ func NewWatchdog() { case t := <-me.dog.C: // log.Info("zookeeper Watchdog() ticked", me.hostname, "Current time: ", t) var counter int - loop := me.machines.SortByName() + loop := me.machines.SortByHostname() for loop.Scan() { - m := loop.Machine() + m := loop.Next() counter += 1 - zood := m.FindPackageByName("zood") + zood := m.Packages.FindByName("zood") if zood == nil { log.Info("machine", m.Hostname, "does not have zood installed") } else {