fix: ensure invalid cron triggers fail a deploy

This commit is contained in:
Jose Diaz-Gonzalez
2025-06-10 23:55:06 -04:00
parent 67003ed469
commit 73be6989ff

View File

@@ -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
}