func (command *WatchCommand) Execute(args []string) error { client, err := rc.TargetClient(Fly.Target) if err != nil { return err } err = rc.ValidateClient(client, Fly.Target) if err != nil { return err } build, err := GetBuild(client, command.Job.JobName, command.Build, command.Job.PipelineName) if err != nil { return err } eventSource, err := client.BuildEvents(fmt.Sprintf("%d", build.ID)) if err != nil { return err } exitCode := eventstream.Render(os.Stdout, eventSource) eventSource.Close() os.Exit(exitCode) return nil }
func (command *WatchCommand) Execute(args []string) error { connection, err := rc.TargetConnection(Fly.Target) if err != nil { log.Fatalln(err) return nil } client := concourse.NewClient(connection) build, err := GetBuild(client, command.Job.JobName, command.Build, command.Job.PipelineName) if err != nil { log.Fatalln(err) } eventSource, err := client.BuildEvents(fmt.Sprintf("%d", build.ID)) if err != nil { log.Println("failed to attach to stream:", err) os.Exit(1) } exitCode := eventstream.Render(os.Stdout, eventSource) eventSource.Close() os.Exit(exitCode) return nil }
func (command *ExecuteCommand) Execute(args []string) error { connection, err := rc.TargetConnection(Fly.Target) if err != nil { log.Fatalln(err) return nil } client := concourse.NewClient(connection) taskConfigFile := command.TaskConfig excludeIgnored := command.ExcludeIgnored atcRequester := deprecated.NewAtcRequester(connection.URL(), connection.HTTPClient()) taskConfig := config.LoadTaskConfig(string(taskConfigFile), args) inputs, err := executehelpers.DetermineInputs( client, taskConfig.Inputs, command.Inputs, command.InputsFrom, ) if err != nil { return err } outputs, err := executehelpers.DetermineOutputs( client, taskConfig.Outputs, command.Outputs, ) if err != nil { return err } build, err := executehelpers.CreateBuild( atcRequester, client, command.Privileged, inputs, outputs, taskConfig, command.Tags, Fly.Target, ) if err != nil { return err } fmt.Println("executing build", build.ID) terminate := make(chan os.Signal, 1) go abortOnSignal(client, terminate, build) signal.Notify(terminate, syscall.SIGINT, syscall.SIGTERM) inputChan := make(chan interface{}) go func() { for _, i := range inputs { if i.Path != "" { executehelpers.Upload(i, excludeIgnored, atcRequester) } } close(inputChan) }() var outputChans []chan (interface{}) if len(outputs) > 0 { for i, output := range outputs { outputChans = append(outputChans, make(chan interface{}, 1)) go func(o executehelpers.Output, outputChan chan<- interface{}) { if o.Path != "" { executehelpers.Download(o, atcRequester) } close(outputChan) }(output, outputChans[i]) } } eventSource, err := client.BuildEvents(fmt.Sprintf("%d", build.ID)) if err != nil { log.Println("failed to attach to stream:", err) os.Exit(1) } exitCode := eventstream.Render(os.Stdout, eventSource) eventSource.Close() <-inputChan if len(outputs) > 0 { for _, outputChan := range outputChans { <-outputChan } } os.Exit(exitCode) return nil }
events := make(chan atc.Event, 100) receivedEvents = events stream.NextEventStub = func() (atc.Event, error) { select { case ev := <-events: return ev, nil default: return nil, io.EOF } } }) JustBeforeEach(func() { exitStatus = eventstream.Render(out, stream) }) Context("when a Log event is received", func() { BeforeEach(func() { receivedEvents <- event.Log{ Payload: "hello", } }) It("prints its payload", func() { Expect(out).To(gbytes.Say("hello")) }) }) Context("when an Error event is received", func() {
func (command *ExecuteCommand) Execute(args []string) error { client, err := rc.TargetClient(Fly.Target) if err != nil { return err } err = rc.ValidateClient(client, Fly.Target) if err != nil { return err } taskConfigFile := command.TaskConfig excludeIgnored := command.ExcludeIgnored taskConfig, err := config.LoadTaskConfig(string(taskConfigFile), args) if err != nil { return err } inputs, err := executehelpers.DetermineInputs( client, taskConfig.Inputs, command.Inputs, command.InputsFrom, ) if err != nil { return err } outputs, err := executehelpers.DetermineOutputs( client, taskConfig.Outputs, command.Outputs, ) if err != nil { return err } build, err := executehelpers.CreateBuild( client, command.Privileged, inputs, outputs, taskConfig, command.Tags, Fly.Target, ) if err != nil { return err } fmt.Println("executing build", build.ID) terminate := make(chan os.Signal, 1) go abortOnSignal(client, terminate, build) signal.Notify(terminate, syscall.SIGINT, syscall.SIGTERM) inputChan := make(chan interface{}) go func() { for _, i := range inputs { if i.Path != "" { executehelpers.Upload(client, i, excludeIgnored) } } close(inputChan) }() var outputChans []chan (interface{}) if len(outputs) > 0 { for i, output := range outputs { outputChans = append(outputChans, make(chan interface{}, 1)) go func(o executehelpers.Output, outputChan chan<- interface{}) { if o.Path != "" { executehelpers.Download(client, o) } close(outputChan) }(output, outputChans[i]) } } eventSource, err := client.BuildEvents(fmt.Sprintf("%d", build.ID)) if err != nil { return err } exitCode := eventstream.Render(os.Stdout, eventSource) eventSource.Close() <-inputChan if len(outputs) > 0 { for _, outputChan := range outputChans { <-outputChan } } os.Exit(exitCode) return nil }