add virtigod versions

This commit is contained in:
Jeff Carr 2025-04-20 17:52:17 -05:00
parent d29e55b0d5
commit 7ef9f39a62
2 changed files with 61 additions and 17 deletions

View File

@ -139,6 +139,11 @@ func updatePackages(m *zoopb.Machine, newp *zoopb.Packages) bool {
changed = true changed = true
} }
} }
if p.Name == "forge" {
if updatePackageVersion(m, p) {
changed = true
}
}
} }
return changed return changed
} }

View File

@ -16,12 +16,13 @@ import (
type stdTableWin struct { type stdTableWin struct {
sync.Mutex sync.Mutex
win *gadgets.GenericWindow // the machines gui window win *gadgets.GenericWindow // the machines gui window
box *gui.Node // the machines gui parent box widget box *gui.Node // the machines gui parent box widget
TB *zoopb.MachinesTable // the machines gui table buffer TB *zoopb.MachinesTable // the machines gui table buffer
version string // the current zood version version string // the current zood version
versionL *gui.Node // label widget to display the current zood version versionL *gui.Node // label widget to display the current zood version
update bool // if the window should be updated outOfDate *gui.Node // checkbox to only show out of date droplets
update bool // if the window should be updated
} }
func (w *stdTableWin) Toggle() { func (w *stdTableWin) Toggle() {
@ -35,22 +36,26 @@ func (w *stdTableWin) Toggle() {
} }
func makeZoodWin() *stdTableWin { func makeZoodWin() *stdTableWin {
zood := new(stdTableWin) stdw := new(stdTableWin)
zood.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here") stdw.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
zood.win.Custom = func() { stdw.win.Custom = func() {
log.Info("test delete window here") log.Info("test delete window here")
} }
grid := zood.win.Group.RawGrid()
grid := stdw.win.Group.RawGrid()
grid.NewButton("save machines.pb", func() { grid.NewButton("save machines.pb", func() {
saveMachineState() saveMachineState()
}) })
grid.NewButton("show active", func() { grid.NewButton("show active", func() {
zood.doMachinesUpgradeTable(me.machines) stdw.doMachinesUpgradeTable(me.machines)
}) })
grid.NewButton("refresh", func() { grid.NewButton("refresh", func() {
refresh() refresh()
}) })
zood.versionL = grid.NewLabel("scan")
stdw.versionL = grid.NewLabel("scan")
grid.NewButton("show out of date", func() { grid.NewButton("show out of date", func() {
found := zoopb.NewMachines() found := zoopb.NewMachines()
all := me.machines.All() all := me.machines.All()
@ -60,14 +65,32 @@ func makeZoodWin() *stdTableWin {
found.Append(m) found.Append(m)
} }
} }
zood.doMachinesUpgradeTable(found) stdw.doMachinesUpgradeTable(found)
}) })
// make a box at the bottom of the window for the protobuf table // make a box at the bottom of the window for the protobuf table
zood.box = zood.win.Bottom.Box().SetProgName("TBOX") stdw.box = stdw.win.Bottom.Box().SetProgName("TBOX")
zood.doMachinesUpgradeTable(me.machines) stdw.doMachinesUpgradeTable(me.machines)
return zood return stdw
}
func (stdw *stdTableWin) refresh() {
if stdw.outOfDate.Checked() {
found := zoopb.NewMachines()
all := me.machines.All()
for all.Scan() {
m := all.Next()
if m.FindVersion("zood") != me.zood.version {
found.Append(m)
}
}
stdw.doMachinesUpgradeTable(found)
return
}
// show all droplets
stdw.doMachinesUpgradeTable(me.machines)
} }
func (zood *stdTableWin) doMachinesUpgradeTable(pb *zoopb.Machines) { func (zood *stdTableWin) doMachinesUpgradeTable(pb *zoopb.Machines) {
@ -145,10 +168,26 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
m.UpgradeCmd = "apt install virtigod" m.UpgradeCmd = "apt install virtigod"
} }
forgebut := t.AddButtonFunc("forge", func(m *zoopb.Machine) string {
ver := m.FindVersion("forge")
if ver == "n/a" {
return ""
}
return ver
})
forgebut.Custom = func(m *zoopb.Machine) {
log.Info("Triggering machine", m.Hostname, "to upgrade forge")
m.Upgrade = true
m.UpgradeCmd = "apt install forge"
}
delf := func(m *zoopb.Machine) string { delf := func(m *zoopb.Machine) string {
return "delete" return "delete"
} }
t.AddButtonFunc("delete", delf) delbut := t.AddButtonFunc("delete", delf)
delbut.Custom = func(m *zoopb.Machine) {
log.Info("Need to delete the protobuf record here", m.Hostname)
}
/* /*
// show if the machine needs to be upgraded // show if the machine needs to be upgraded