volcano.sh/volcano@v1.9.0/pkg/cli/job/resume.go (about) 1 /* 2 Copyright 2018 The Volcano Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package job 18 19 import ( 20 "fmt" 21 22 "github.com/spf13/cobra" 23 24 "volcano.sh/apis/pkg/apis/bus/v1alpha1" 25 "volcano.sh/volcano/pkg/cli/util" 26 ) 27 28 type resumeFlags struct { 29 commonFlags 30 31 Namespace string 32 JobName string 33 } 34 35 var resumeJobFlags = &resumeFlags{} 36 37 // InitResumeFlags init resume command flags. 38 func InitResumeFlags(cmd *cobra.Command) { 39 initFlags(cmd, &resumeJobFlags.commonFlags) 40 41 cmd.Flags().StringVarP(&resumeJobFlags.Namespace, "namespace", "n", "default", "the namespace of job") 42 cmd.Flags().StringVarP(&resumeJobFlags.JobName, "name", "N", "", "the name of job") 43 } 44 45 // ResumeJob resumes the job. 46 func ResumeJob() error { 47 config, err := util.BuildConfig(resumeJobFlags.Master, resumeJobFlags.Kubeconfig) 48 if err != nil { 49 return err 50 } 51 if resumeJobFlags.JobName == "" { 52 err := fmt.Errorf("job name is mandatory to resume a particular job") 53 return err 54 } 55 56 return createJobCommand(config, 57 resumeJobFlags.Namespace, resumeJobFlags.JobName, 58 v1alpha1.ResumeJobAction) 59 }