fix: ensure invalid cron triggers fail a deploy
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package appjson
|
package appjson
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"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
|
// TODO: add validation to app.json file by ensuring it can be deserialized
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user