feat: add initial scheduled task implementation

This functionality enables users to manage a global crontab for the Dokku user that contains all scheduled tasks across all apps. Alternative schedulers can implement cron tasks as desired.
This commit is contained in:
Jose Diaz-Gonzalez committed 2021-01-20 14:49:48 -05:00
1 parent e00e498e50
commit f7ef14d737
23 files changed
+1026 -391

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package cron
import (
"strconv"
"github.com/dokku/dokku/plugins/common"
)
// ReportSingleApp is an internal function that displays the cron report for one or more apps
func ReportSingleApp(appName, infoFlag string) error {
if err := common.VerifyAppName(appName); err != nil {
return err
}
flags := map[string]common.ReportFunc{
"--cron-task-count": reportTasks,
}
flagKeys := []string{}
for flagKey := range flags {
flagKeys = append(flagKeys, flagKey)
}
trimPrefix := false
uppercaseFirstCharacter := true
infoFlags := common.CollectReport(appName, infoFlag, flags)
return common.ReportSingleApp("cron", appName, infoFlag, infoFlags, flagKeys, trimPrefix, uppercaseFirstCharacter)
}
func reportTasks(appName string) string {
c, _ := fetchCronEntries(appName)
return strconv.Itoa(len(c))
}