refactor: rename cron entry to cron task
This naming better suits what it is we are fetching.
This commit is contained in:
@@ -66,15 +66,15 @@ func (t TemplateCommand) CronCommand() string {
|
||||
return fmt.Sprintf("dokku run --cron-id %s %s %s", t.ID, t.App, t.Command)
|
||||
}
|
||||
|
||||
// FetchCronEntriesInput is the input for the FetchCronEntries function
|
||||
type FetchCronEntriesInput struct {
|
||||
// FetchCronTasksInput is the input for the FetchCronTasks function
|
||||
type FetchCronTasksInput struct {
|
||||
AppName string
|
||||
AppJSON *appjson.AppJSON
|
||||
WarnToFailure bool
|
||||
}
|
||||
|
||||
// FetchCronEntries returns a list of cron commands for a given app
|
||||
func FetchCronEntries(input FetchCronEntriesInput) ([]TemplateCommand, error) {
|
||||
// FetchCronTasks returns a list of cron commands for a given app
|
||||
func FetchCronTasks(input FetchCronTasksInput) ([]TemplateCommand, error) {
|
||||
appName := input.AppName
|
||||
commands := []TemplateCommand{}
|
||||
isMaintenance := reportComputedMaintenance(appName) == "true"
|
||||
@@ -129,10 +129,10 @@ func FetchCronEntries(input FetchCronEntriesInput) ([]TemplateCommand, error) {
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
// FetchGlobalCronEntries returns a list of global cron commands
|
||||
// FetchGlobalCronTasks returns a list of global cron commands
|
||||
// This function should only be used for the cron:list --global command
|
||||
// and not internally by the cron plugin
|
||||
func FetchGlobalCronEntries() ([]TemplateCommand, error) {
|
||||
func FetchGlobalCronTasks() ([]TemplateCommand, error) {
|
||||
commands := []TemplateCommand{}
|
||||
response, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||
Trigger: "cron-entries",
|
||||
|
||||
@@ -41,7 +41,7 @@ func reportMailto(_ string) string {
|
||||
}
|
||||
|
||||
func reportTasks(appName string) string {
|
||||
c, _ := FetchCronEntries(FetchCronEntriesInput{AppName: appName})
|
||||
c, _ := FetchCronTasks(FetchCronTasksInput{AppName: appName})
|
||||
return strconv.Itoa(len(c))
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ func CommandList(appName string, format string) error {
|
||||
return fmt.Errorf("Invalid format specified, supported formats: json, stdout")
|
||||
}
|
||||
|
||||
var entries []TemplateCommand
|
||||
var tasks []TemplateCommand
|
||||
if appName == "--global" {
|
||||
var err error
|
||||
entries, err = FetchGlobalCronEntries()
|
||||
tasks, err = FetchGlobalCronTasks()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func CommandList(appName string, format string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
entries, err = FetchCronEntries(FetchCronEntriesInput{AppName: appName})
|
||||
tasks, err = FetchCronTasks(FetchCronTasksInput{AppName: appName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -42,8 +42,8 @@ func CommandList(appName string, format string) error {
|
||||
|
||||
if format == "stdout" {
|
||||
output := []string{"ID | Schedule | Maintenance | Command"}
|
||||
for _, entry := range entries {
|
||||
output = append(output, fmt.Sprintf("%s | %s | %t | %s", entry.ID, entry.Schedule, entry.Maintenance, entry.Command))
|
||||
for _, task := range tasks {
|
||||
output = append(output, fmt.Sprintf("%s | %s | %t | %s", task.ID, task.Schedule, task.Maintenance, task.Command))
|
||||
}
|
||||
|
||||
result := columnize.SimpleFormat(output)
|
||||
@@ -51,7 +51,7 @@ func CommandList(appName string, format string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
out, err := json.Marshal(entries)
|
||||
out, err := json.Marshal(tasks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func CommandRun(appName string, cronID string, detached bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
entries, err := FetchCronEntries(FetchCronEntriesInput{AppName: appName})
|
||||
tasks, err := FetchCronTasks(FetchCronTasksInput{AppName: appName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -98,9 +98,9 @@ func CommandRun(appName string, cronID string, detached bool) error {
|
||||
}
|
||||
|
||||
command := ""
|
||||
for _, entry := range entries {
|
||||
if entry.ID == cronID {
|
||||
command = entry.Command
|
||||
for _, task := range tasks {
|
||||
if task.ID == cronID {
|
||||
command = task.Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ MAILTO={{ .Mailto }}
|
||||
PATH=/usr/local/bin:/usr/bin:/bin
|
||||
SHELL=/bin/bash
|
||||
|
||||
{{ range $entry := .Commands -}}
|
||||
{{ $entry.Schedule }} {{ $entry.CronCommand }}
|
||||
{{ range $task := .Commands -}}
|
||||
{{ $task.Schedule }} {{ $task.CronCommand }}
|
||||
{{ end -}}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TriggerCronGetProperty(appName string, key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerAppJSONIsValid validates the cron entries for a given app
|
||||
// TriggerAppJSONIsValid validates the cron tasks for a given app
|
||||
func TriggerAppJSONIsValid(appName string, appJSONPath string) error {
|
||||
if !common.FileExists(appJSONPath) {
|
||||
return nil
|
||||
@@ -35,7 +35,7 @@ func TriggerAppJSONIsValid(appName string, appJSONPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = FetchCronEntries(FetchCronEntriesInput{
|
||||
_, err = FetchCronTasks(FetchCronTasksInput{
|
||||
AppName: appName,
|
||||
AppJSON: &appJSON,
|
||||
WarnToFailure: true,
|
||||
|
||||
Reference in New Issue
Block a user