feat: turn warnings to failures when running validation against an app.json file

This commit is contained in:
Jose Diaz-Gonzalez
2025-06-23 01:03:10 -04:00
parent 7e37f9dc79
commit 885178eed5
2 changed files with 16 additions and 3 deletions

View File

@@ -64,8 +64,9 @@ func (t TemplateCommand) CronCommand() string {
// FetchCronEntriesInput is the input for the FetchCronEntries function // FetchCronEntriesInput is the input for the FetchCronEntries function
type FetchCronEntriesInput struct { type FetchCronEntriesInput struct {
AppName string AppName string
AppJSON *appjson.AppJSON AppJSON *appjson.AppJSON
WarnToFailure bool
} }
// FetchCronEntries returns a list of cron commands for a given app // FetchCronEntries returns a list of cron commands for a given app
@@ -89,11 +90,19 @@ func FetchCronEntries(input FetchCronEntriesInput) ([]TemplateCommand, error) {
for i, c := range input.AppJSON.Cron { for i, c := range input.AppJSON.Cron {
if c.Command == "" { if c.Command == "" {
if input.WarnToFailure {
return commands, fmt.Errorf("Missing cron command for app %s (index %d)", appName, i)
}
common.LogWarn(fmt.Sprintf("Missing cron command for app %s (index %d)", appName, i)) common.LogWarn(fmt.Sprintf("Missing cron command for app %s (index %d)", appName, i))
continue continue
} }
if c.Schedule == "" { if c.Schedule == "" {
if input.WarnToFailure {
return commands, fmt.Errorf("Missing cron schedule for app %s (index %d)", appName, i)
}
common.LogWarn(fmt.Sprintf("Missing cron schedule for app %s (index %d)", appName, i)) common.LogWarn(fmt.Sprintf("Missing cron schedule for app %s (index %d)", appName, i))
continue continue
} }

View File

@@ -35,7 +35,11 @@ func TriggerAppJSONIsValid(appName string, appJSONPath string) error {
return err return err
} }
_, err = FetchCronEntries(FetchCronEntriesInput{AppName: appName, AppJSON: &appJSON}) _, err = FetchCronEntries(FetchCronEntriesInput{
AppName: appName,
AppJSON: &appJSON,
WarnToFailure: true,
})
if err != nil { if err != nil {
return err return err
} }