feat: expose the concurrency policy when fetching cron entries
Also add some validation to ensure invalid values are not specified.
This commit is contained in:
@@ -47,6 +47,9 @@ type CronTask struct {
|
|||||||
// Schedule is the cron schedule
|
// Schedule is the cron schedule
|
||||||
Schedule string `json:"schedule"`
|
Schedule string `json:"schedule"`
|
||||||
|
|
||||||
|
// ConcurrencyPolicy is the concurrency policy for the cron command
|
||||||
|
ConcurrencyPolicy string `json:"concurrency_policy"`
|
||||||
|
|
||||||
// AltCommand is an alternate command to run
|
// AltCommand is an alternate command to run
|
||||||
AltCommand string `json:"-"`
|
AltCommand string `json:"-"`
|
||||||
|
|
||||||
@@ -148,12 +151,19 @@ func FetchCronTasks(input FetchCronTasksInput) ([]CronTask, error) {
|
|||||||
maintenance = boolValue
|
maintenance = boolValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if c.ConcurrencyPolicy == "" {
|
||||||
|
c.ConcurrencyPolicy = "allow"
|
||||||
|
}
|
||||||
|
if c.ConcurrencyPolicy != "allow" && c.ConcurrencyPolicy != "forbid" && c.ConcurrencyPolicy != "replace" {
|
||||||
|
return tasks, fmt.Errorf("Invalid cron concurrency policy for app %s (schedule %s): %s", appName, c.Schedule, c.ConcurrencyPolicy)
|
||||||
|
}
|
||||||
|
|
||||||
tasks = append(tasks, CronTask{
|
tasks = append(tasks, CronTask{
|
||||||
App: appName,
|
App: appName,
|
||||||
Command: c.Command,
|
Command: c.Command,
|
||||||
Schedule: c.Schedule,
|
Schedule: c.Schedule,
|
||||||
ID: cronID,
|
ID: cronID,
|
||||||
|
ConcurrencyPolicy: c.ConcurrencyPolicy,
|
||||||
Maintenance: isAppCronInMaintenance || maintenance,
|
Maintenance: isAppCronInMaintenance || maintenance,
|
||||||
AppInMaintenance: isAppCronInMaintenance,
|
AppInMaintenance: isAppCronInMaintenance,
|
||||||
TaskInMaintenance: maintenance,
|
TaskInMaintenance: maintenance,
|
||||||
|
|||||||
Reference in New Issue
Block a user