forked from volcano-sh/volcano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.go
76 lines (66 loc) · 1.63 KB
/
job.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"github.com/spf13/cobra"
"volcano.sh/volcano/pkg/cli/job"
)
func buildJobCmd() *cobra.Command {
jobCmd := &cobra.Command{
Use: "job",
Short: "vcctl command line operation job",
}
jobRunCmd := &cobra.Command{
Use: "run",
Short: "run job by parameters from the command line",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.RunJob())
},
}
job.InitRunFlags(jobRunCmd)
jobCmd.AddCommand(jobRunCmd)
jobListCmd := &cobra.Command{
Use: "list",
Short: "list job information",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.ListJobs())
},
}
job.InitListFlags(jobListCmd)
jobCmd.AddCommand(jobListCmd)
jobViewCmd := &cobra.Command{
Use: "view",
Short: "show job information",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.ViewJob())
},
}
job.InitViewFlags(jobViewCmd)
jobCmd.AddCommand(jobViewCmd)
jobSuspendCmd := &cobra.Command{
Use: "suspend",
Short: "abort a job",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.SuspendJob())
},
}
job.InitSuspendFlags(jobSuspendCmd)
jobCmd.AddCommand(jobSuspendCmd)
jobResumeCmd := &cobra.Command{
Use: "resume",
Short: "resume a job",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.ResumeJob())
},
}
job.InitResumeFlags(jobResumeCmd)
jobCmd.AddCommand(jobResumeCmd)
jobDelCmd := &cobra.Command{
Use: "delete",
Short: "delete a job ",
Run: func(cmd *cobra.Command, args []string) {
checkError(cmd, job.DeleteJob())
},
}
job.InitDeleteFlags(jobDelCmd)
jobCmd.AddCommand(jobDelCmd)
return jobCmd
}