github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/commands/pause_job.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/pf-qiu/concourse/v6/fly/commands/internal/flaghelpers" 7 "github.com/pf-qiu/concourse/v6/fly/rc" 8 "github.com/pf-qiu/concourse/v6/go-concourse/concourse" 9 ) 10 11 type PauseJobCommand struct { 12 Job flaghelpers.JobFlag `short:"j" long:"job" required:"true" value-name:"PIPELINE/JOB" description:"Name of a job to pause"` 13 Team string `long:"team" description:"Name of the team to which the job belongs, if different from the target default"` 14 } 15 16 func (command *PauseJobCommand) Execute(args []string) error { 17 jobName := command.Job.JobName 18 pipelineRef := command.Job.PipelineRef 19 target, err := rc.LoadTarget(Fly.Target, Fly.Verbose) 20 if err != nil { 21 return err 22 } 23 24 err = target.Validate() 25 if err != nil { 26 return err 27 } 28 29 var team concourse.Team 30 if command.Team != "" { 31 team, err = target.FindTeam(command.Team) 32 if err != nil { 33 return err 34 } 35 } else { 36 team = target.Team() 37 } 38 39 found, err := team.PauseJob(pipelineRef, jobName) 40 if err != nil { 41 return err 42 } 43 44 if !found { 45 return fmt.Errorf("%s/%s not found on team %s\n", pipelineRef.String(), jobName, team.Name()) 46 } 47 48 fmt.Printf("paused '%s'\n", jobName) 49 50 return nil 51 }