github.com/chenbh/concourse/v6@v6.4.2/fly/commands/pause_job.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/chenbh/concourse/v6/fly/commands/internal/flaghelpers" 7 "github.com/chenbh/concourse/v6/fly/rc" 8 "github.com/chenbh/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 pipelineName, jobName := command.Job.PipelineName, command.Job.JobName 18 target, err := rc.LoadTarget(Fly.Target, Fly.Verbose) 19 if err != nil { 20 return err 21 } 22 23 err = target.Validate() 24 if err != nil { 25 return err 26 } 27 28 var team concourse.Team 29 if command.Team != "" { 30 team, err = target.FindTeam(command.Team) 31 if err != nil { 32 return err 33 } 34 } else { 35 team = target.Team() 36 } 37 38 found, err := team.PauseJob(pipelineName, jobName) 39 if err != nil { 40 return err 41 } 42 43 if !found { 44 return fmt.Errorf("%s/%s not found on team %s\n", pipelineName, jobName, team.Name()) 45 } 46 47 fmt.Printf("paused '%s'\n", jobName) 48 49 return nil 50 }