fix: skip cron entries that are missing a command or a schedule
This commit is contained in:
1 file changed
+12
-1
+12
-1
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
appjson "github.com/dokku/dokku/plugins/app-json"
|
appjson "github.com/dokku/dokku/plugins/app-json"
|
||||||
|
"github.com/dokku/dokku/plugins/common"
|
||||||
|
|
||||||
"github.com/multiformats/go-base36"
|
"github.com/multiformats/go-base36"
|
||||||
cronparser "github.com/robfig/cron/v3"
|
cronparser "github.com/robfig/cron/v3"
|
||||||
@@ -75,7 +76,17 @@ func FetchCronEntries(appName string) ([]TemplateCommand, error) {
|
|||||||
return commands, nil
|
return commands, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range appJSON.Cron {
|
for i, c := range appJSON.Cron {
|
||||||
|
if c.Command == "" {
|
||||||
|
common.LogWarn(fmt.Sprintf("Missing cron command for app %s (index %d)", appName, i))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Schedule == "" {
|
||||||
|
common.LogWarn(fmt.Sprintf("Missing cron schedule for app %s (index %d)", appName, i))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
parser := cronparser.NewParser(cronparser.Minute | cronparser.Hour | cronparser.Dom | cronparser.Month | cronparser.Dow | cronparser.Descriptor)
|
parser := cronparser.NewParser(cronparser.Minute | cronparser.Hour | cronparser.Dom | cronparser.Month | cronparser.Dow | cronparser.Descriptor)
|
||||||
_, err := parser.Parse(c.Schedule)
|
_, err := parser.Parse(c.Schedule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user