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
}
}
if p.Name == "forge" {
if updatePackageVersion(m, p) {
changed = true
}
}
}
return changed
}

View File

@ -21,6 +21,7 @@ type stdTableWin struct {
TB *zoopb.MachinesTable // the machines gui table buffer
version string // the current zood version
versionL *gui.Node // label widget to display the current zood version
outOfDate *gui.Node // checkbox to only show out of date droplets
update bool // if the window should be updated
}
@ -35,22 +36,26 @@ func (w *stdTableWin) Toggle() {
}
func makeZoodWin() *stdTableWin {
zood := new(stdTableWin)
zood.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
zood.win.Custom = func() {
stdw := new(stdTableWin)
stdw.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
stdw.win.Custom = func() {
log.Info("test delete window here")
}
grid := zood.win.Group.RawGrid()
grid := stdw.win.Group.RawGrid()
grid.NewButton("save machines.pb", func() {
saveMachineState()
})
grid.NewButton("show active", func() {
zood.doMachinesUpgradeTable(me.machines)
stdw.doMachinesUpgradeTable(me.machines)
})
grid.NewButton("refresh", func() {
refresh()
})
zood.versionL = grid.NewLabel("scan")
stdw.versionL = grid.NewLabel("scan")
grid.NewButton("show out of date", func() {
found := zoopb.NewMachines()
all := me.machines.All()
@ -60,14 +65,32 @@ func makeZoodWin() *stdTableWin {
found.Append(m)
}
}
zood.doMachinesUpgradeTable(found)
stdw.doMachinesUpgradeTable(found)
})
// make a box at the bottom of the window for the protobuf table
zood.box = zood.win.Bottom.Box().SetProgName("TBOX")
zood.doMachinesUpgradeTable(me.machines)
stdw.box = stdw.win.Bottom.Box().SetProgName("TBOX")
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) {
@ -145,10 +168,26 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
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 {
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