volcano.sh/volcano@v1.9.0/cmd/cli/job.go (about) 1 package main 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "volcano.sh/volcano/pkg/cli/job" 7 ) 8 9 func buildJobCmd() *cobra.Command { 10 jobCmd := &cobra.Command{ 11 Use: "job", 12 Short: "vcctl command line operation job", 13 } 14 15 jobRunCmd := &cobra.Command{ 16 Use: "run", 17 Short: "run job by parameters from the command line", 18 Run: func(cmd *cobra.Command, args []string) { 19 checkError(cmd, job.RunJob()) 20 }, 21 } 22 job.InitRunFlags(jobRunCmd) 23 jobCmd.AddCommand(jobRunCmd) 24 25 jobListCmd := &cobra.Command{ 26 Use: "list", 27 Short: "list job information", 28 Run: func(cmd *cobra.Command, args []string) { 29 checkError(cmd, job.ListJobs()) 30 }, 31 } 32 job.InitListFlags(jobListCmd) 33 jobCmd.AddCommand(jobListCmd) 34 35 jobViewCmd := &cobra.Command{ 36 Use: "view", 37 Short: "show job information", 38 Run: func(cmd *cobra.Command, args []string) { 39 checkError(cmd, job.ViewJob()) 40 }, 41 } 42 job.InitViewFlags(jobViewCmd) 43 jobCmd.AddCommand(jobViewCmd) 44 45 jobSuspendCmd := &cobra.Command{ 46 Use: "suspend", 47 Short: "abort a job", 48 Run: func(cmd *cobra.Command, args []string) { 49 checkError(cmd, job.SuspendJob()) 50 }, 51 } 52 job.InitSuspendFlags(jobSuspendCmd) 53 jobCmd.AddCommand(jobSuspendCmd) 54 55 jobResumeCmd := &cobra.Command{ 56 Use: "resume", 57 Short: "resume a job", 58 Run: func(cmd *cobra.Command, args []string) { 59 checkError(cmd, job.ResumeJob()) 60 }, 61 } 62 job.InitResumeFlags(jobResumeCmd) 63 jobCmd.AddCommand(jobResumeCmd) 64 65 jobDelCmd := &cobra.Command{ 66 Use: "delete", 67 Short: "delete a job", 68 Run: func(cmd *cobra.Command, args []string) { 69 checkError(cmd, job.DeleteJob()) 70 }, 71 } 72 job.InitDeleteFlags(jobDelCmd) 73 jobCmd.AddCommand(jobDelCmd) 74 75 return jobCmd 76 }