github.com/chenbh/concourse/v6@v6.4.2/fly/commands/expose_pipeline.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/chenbh/concourse/v6/fly/commands/internal/displayhelpers" 7 "github.com/chenbh/concourse/v6/fly/commands/internal/flaghelpers" 8 "github.com/chenbh/concourse/v6/fly/rc" 9 ) 10 11 type ExposePipelineCommand struct { 12 Pipeline flaghelpers.PipelineFlag `short:"p" long:"pipeline" required:"true" description:"Pipeline to expose"` 13 } 14 15 func (command *ExposePipelineCommand) Validate() error { 16 _, err := command.Pipeline.Validate() 17 return err 18 } 19 20 func (command *ExposePipelineCommand) Execute(args []string) error { 21 err := command.Validate() 22 if err != nil { 23 return err 24 } 25 26 pipelineName := string(command.Pipeline) 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 found, err := target.Team().ExposePipeline(pipelineName) 39 if err != nil { 40 return err 41 } 42 43 if found { 44 fmt.Printf("exposed '%s'\n", pipelineName) 45 } else { 46 displayhelpers.Failf("pipeline '%s' not found\n", pipelineName) 47 } 48 49 return nil 50 }