-
Notifications
You must be signed in to change notification settings - Fork 127
/
cancel.go
36 lines (33 loc) · 1.11 KB
/
cancel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import (
"github.com/spf13/cobra"
"github.com/armadaproject/armada/internal/armadactl"
)
func cancelCmd() *cobra.Command {
a := armadactl.New()
cmd := &cobra.Command{
Use: "cancel",
Short: "Cancels jobs in armada.",
Long: `Cancels jobs. If queue and jobset are provided then all jobs in that jobset will be cancelled. A job id may also be provided in which case only that job is cancelled`,
Args: cobra.ExactArgs(0),
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
jobId, _ := cmd.Flags().GetString("jobId")
queue, _ := cmd.Flags().GetString("queue")
jobSetId, _ := cmd.Flags().GetString("jobSet")
return a.Cancel(queue, jobSetId, jobId)
},
}
cmd.Flags().String("jobId", "", "job to cancel (optional)")
cmd.Flags().String("queue", "", "queue to cancel jobs from")
cmd.Flags().String("jobSet", "", "jobSet to cancel")
if err := cmd.MarkFlagRequired("queue"); err != nil {
panic(err)
}
if err := cmd.MarkFlagRequired("jobSet"); err != nil {
panic(err)
}
return cmd
}