feat: implement app-json-is-valid plugin trigger

This commit is contained in:
Jose Diaz-Gonzalez
2025-06-19 02:19:08 -04:00
parent ed851fe399
commit 4ae9cca6f1
9 changed files with 87 additions and 49 deletions

View File

@@ -62,21 +62,32 @@ 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 {
AppName string
AppJSON *appjson.AppJSON
}
// FetchCronEntries returns a list of cron commands for a given app
func FetchCronEntries(appName string) ([]TemplateCommand, error) {
func FetchCronEntries(input FetchCronEntriesInput) ([]TemplateCommand, error) {
appName := input.AppName
commands := []TemplateCommand{}
isMaintenance := reportComputedMaintenance(appName) == "true"
appJSON, err := appjson.GetAppJSON(appName)
if err != nil {
return commands, fmt.Errorf("Unable to fetch app.json for app %s: %s", appName, err.Error())
if input.AppJSON == nil {
appJSON, err := appjson.GetAppJSON(appName)
if err != nil {
return commands, fmt.Errorf("Unable to fetch app.json for app %s: %s", appName, err.Error())
}
input.AppJSON = &appJSON
}
if appJSON.Cron == nil {
if input.AppJSON.Cron == nil {
return commands, nil
}
for i, c := range appJSON.Cron {
for i, c := range input.AppJSON.Cron {
if c.Command == "" {
common.LogWarn(fmt.Sprintf("Missing cron command for app %s (index %d)", appName, i))
continue