diff --git a/cmd/snapctl/task.go b/cmd/snapctl/task.go index 31c6f7483..605ae4e0f 100644 --- a/cmd/snapctl/task.go +++ b/cmd/snapctl/task.go @@ -343,6 +343,11 @@ func createTaskUsingTaskManifest(ctx *cli.Context) error { return fmt.Errorf("Unsupported file type %s\n", ext) } + // Validate task manifest includes schedule, workflow, and version + if err := validateTask(t); err != nil { + return err + } + // merge any CLI options specified by the user (if any) into the current task; // if an error is encountered, return it if err := t.mergeCliOptions(ctx); err != nil { @@ -699,3 +704,20 @@ func min(a, b int) int { } return b } + +func validateTask(t task) error { + if err := validateScheduleExists(t.Schedule); err != nil { + return err + } + return nil +} + +func validateScheduleExists(schedule *client.Schedule) error { + if schedule == nil { + return fmt.Errorf("Error: Task manifest did not include a schedule") + } + if *schedule == (client.Schedule{}) { + return fmt.Errorf("Error: Task manifest included an empty schedule. Task manifests need to include a schedule.") + } + return nil +}