fix: skip cron entries that are missing a command or a schedule

This commit is contained in:
Jose Diaz-Gonzalez
2025-06-10 23:39:35 -04:00
parent 2758b3cc47
commit 67003ed469

View File

@@ -4,6 +4,7 @@ import (
"fmt"
appjson "github.com/dokku/dokku/plugins/app-json"
"github.com/dokku/dokku/plugins/common"
"github.com/multiformats/go-base36"
cronparser "github.com/robfig/cron/v3"
@@ -75,7 +76,17 @@ func FetchCronEntries(appName string) ([]TemplateCommand, error) {
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)
_, err := parser.Parse(c.Schedule)
if err != nil {