github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/commands/hide_pipeline.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/pf-qiu/concourse/v6/fly/commands/internal/displayhelpers" 7 "github.com/pf-qiu/concourse/v6/fly/commands/internal/flaghelpers" 8 "github.com/pf-qiu/concourse/v6/fly/rc" 9 "github.com/pf-qiu/concourse/v6/go-concourse/concourse" 10 ) 11 12 type HidePipelineCommand struct { 13 Pipeline flaghelpers.PipelineFlag `short:"p" long:"pipeline" required:"true" description:"Pipeline to hide"` 14 Team string `long:"team" description:"Name of the team to which the pipeline belongs, if different from the target default"` 15 } 16 17 func (command *HidePipelineCommand) Validate() error { 18 _, err := command.Pipeline.Validate() 19 return err 20 } 21 22 func (command *HidePipelineCommand) Execute(args []string) error { 23 err := command.Validate() 24 if err != nil { 25 return err 26 } 27 28 target, err := rc.LoadTarget(Fly.Target, Fly.Verbose) 29 if err != nil { 30 return err 31 } 32 33 err = target.Validate() 34 if err != nil { 35 return err 36 } 37 38 var team concourse.Team 39 if command.Team != "" { 40 team, err = target.FindTeam(command.Team) 41 if err != nil { 42 return err 43 } 44 } else { 45 team = target.Team() 46 } 47 48 pipelineRef := command.Pipeline.Ref() 49 found, err := team.HidePipeline(pipelineRef) 50 if err != nil { 51 return err 52 } 53 54 if found { 55 fmt.Printf("hid '%s'\n", pipelineRef.String()) 56 } else { 57 displayhelpers.Failf("pipeline '%s' not found\n", pipelineRef.String()) 58 } 59 60 return nil 61 }