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
parent
582cca37d6
commit
4867f5361d
|
|
@ -82,12 +82,14 @@ func (c *CronJob) bindKeys(aa *ui.KeyActions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
fqn := c.GetTable().GetSelectedItem()
|
fqns := c.GetTable().GetSelectedItems()
|
||||||
if fqn == "" {
|
if len(fqns) == 0 {
|
||||||
return evt
|
return evt
|
||||||
}
|
}
|
||||||
|
msg := fmt.Sprintf("Trigger CronJob: %s?", fqns[0])
|
||||||
msg := fmt.Sprintf("Trigger Cronjob %s?", fqn)
|
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() {
|
dialog.ShowConfirm(c.App().Styles.Dialog(), c.App().Content.Pages, "Confirm Job Trigger", msg, func() {
|
||||||
res, err := dao.AccessorFor(c.App().factory, c.GVR())
|
res, err := dao.AccessorFor(c.App().factory, c.GVR())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -100,11 +102,13 @@ func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := runner.Run(fqn); err != nil {
|
for _, fqn := range fqns {
|
||||||
c.App().Flash().Errf("Cronjob trigger failed %v", err)
|
if err := runner.Run(fqn); err != nil {
|
||||||
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() {})
|
}, func() {})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue