new FindVersion()

This commit is contained in:
Jeff Carr 2025-03-23 11:43:42 -05:00
parent a24c5f67e5
commit 0a70f3bdde
3 changed files with 6 additions and 14 deletions

View File

@ -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)
}

View File

@ -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)

View File

@ -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
}