Trigger all marked cronjobs (#3177)

Currently, running the cronjob trigger command supports
triggering the currently selected cronjob only. It would
be nice if this feature supported triggering all marked
cronjobs in the case that there are marked cronjobs - in
a similar fashion to scaling deployments or generally
deleting resources.

Let's modify cronjob triggering to support the case where
the user has marked multiple cronjobs in the cronjob view.
mine
DanCocking 2025-03-10 06:40:20 +11:00 committed by GitHub
parent 582cca37d6
commit 4867f5361d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 8 deletions

View File

@ -82,12 +82,14 @@ func (c *CronJob) bindKeys(aa *ui.KeyActions) {
}
func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey {
fqn := c.GetTable().GetSelectedItem()
if fqn == "" {
fqns := c.GetTable().GetSelectedItems()
if len(fqns) == 0 {
return evt
}
msg := fmt.Sprintf("Trigger Cronjob %s?", fqn)
msg := fmt.Sprintf("Trigger CronJob: %s?", fqns[0])
if len(fqns) > 1 {
msg = fmt.Sprintf("Trigger %d CronJobs?", len(fqns))
}
dialog.ShowConfirm(c.App().Styles.Dialog(), c.App().Content.Pages, "Confirm Job Trigger", msg, func() {
res, err := dao.AccessorFor(c.App().factory, c.GVR())
if err != nil {
@ -100,11 +102,13 @@ func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey {
return
}
for _, fqn := range fqns {
if err := runner.Run(fqn); err != nil {
c.App().Flash().Errf("Cronjob trigger failed %v", err)
return
c.App().Flash().Errf("CronJob trigger failed for %s: %v", fqn, err)
} else {
c.App().Flash().Infof("Triggered Job %s %s", c.GVR(), fqn)
}
}
c.App().Flash().Infof("Triggering Job %s %s", c.GVR(), fqn)
}, func() {})
return nil