mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
fix: ensure invalid cron triggers fail a deploy
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package appjson
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -140,6 +141,35 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if hasAppJSON(appName) {
|
||||
b, err := os.ReadFile(processSpecificAppJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
content := strings.TrimSpace(string(b))
|
||||
if content == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var appJSON AppJSON
|
||||
if err := json.Unmarshal([]byte(content), &appJSON); err != nil {
|
||||
return fmt.Errorf("Unable to unmarshal app.json: %v", err.Error())
|
||||
}
|
||||
|
||||
if appJSON.Cron != nil {
|
||||
for i, c := range appJSON.Cron {
|
||||
if c.Command == "" {
|
||||
return fmt.Errorf("Missing cron command for app %s (index %d)", appName, i)
|
||||
}
|
||||
|
||||
if c.Schedule == "" {
|
||||
return fmt.Errorf("Missing cron schedule for app %s (index %d)", appName, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add validation to app.json file by ensuring it can be deserialized
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user