From 0a70f3bdde6bc1e00a73aca2eec055874cd39212 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 23 Mar 2025 11:43:42 -0500 Subject: [PATCH] new FindVersion() --- doGui.go | 2 +- http.go | 2 +- windowZood.go | 16 ++++------------ 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/doGui.go b/doGui.go index 13e1a99..3b3c350 100644 --- a/doGui.go +++ b/doGui.go @@ -27,7 +27,7 @@ func refresh() { m := all.Next() if me.hostname == m.Hostname { // this is me! This is the version of zood that should be installed everywhere - v := findVersion(m, "zood") + v := m.FindVersion("zood") me.zood.version = v me.zood.versionL.SetText(v) } diff --git a/http.go b/http.go index 8eac404..8103989 100644 --- a/http.go +++ b/http.go @@ -86,7 +86,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { var bad int for m := range me.machines.IterAll() { count += 1 - if findVersion(m, "zood") != me.zood.version { + if m.FindVersion("zood") != me.zood.version { if m.SinceLastUpdate() > 10*time.Minute { // skip machines that have not been updated in the last 10 minutes log.Info("ignoring old machine", m.Hostname) diff --git a/windowZood.go b/windowZood.go index 01bcf28..38688d1 100644 --- a/windowZood.go +++ b/windowZood.go @@ -56,7 +56,7 @@ func makeZoodWin() *stdTableWin { all := me.machines.All() for all.Scan() { m := all.Next() - if findVersion(m, "zood") != me.zood.version { + if m.FindVersion("zood") != me.zood.version { found.Append(m) } } @@ -104,7 +104,7 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { upbut := t.AddButtonFunc("upgrade", func(m *zoopb.Machine) string { if me.zood != nil { - mver := findVersion(m, "zood") + mver := m.FindVersion("zood") if mver == me.zood.version { return "" } else { @@ -130,10 +130,10 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { }) t.AddStringFunc("zood", func(m *zoopb.Machine) string { - return findVersion(m, "zood") + return m.FindVersion("zood") }) virtbut := t.AddButtonFunc("virtigod", func(m *zoopb.Machine) string { - ver := findVersion(m, "virtigod") + ver := m.FindVersion("virtigod") if ver == "n/a" { return "" } @@ -167,11 +167,3 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { t.ShowTable() return t } - -func findVersion(m *zoopb.Machine, pkgname string) string { - zood := m.Packages.FindByName(pkgname) - if zood == nil { - return "n/a" - } - return zood.Version -}