From 2f7fc2ab5f01ab45531116ae86c3000c0effb311 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 26 Apr 2022 12:11:58 -0500 Subject: [PATCH] refactor: rename logCtx to streamCtx I will probably use StreamBuild to stream events as well as logs in the Kubernetes runtime, so let's just add rename this var now for clarity. --- executor/linux/build.go | 12 ++++++------ executor/local/build.go | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/executor/linux/build.go b/executor/linux/build.go index bedad3e4..9d43477e 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -497,12 +497,12 @@ func (c *client) StreamBuild(ctx context.Context) error { // create an error group with the parent context // // https://pkg.go.dev/golang.org/x/sync/errgroup?tab=doc#WithContext - logs, logCtx := errgroup.WithContext(ctx) + streams, streamCtx := errgroup.WithContext(ctx) defer func() { c.Logger.Trace("waiting for stream functions to return") - err := logs.Wait() + err := streams.Wait() if err != nil { c.Logger.Errorf("error in a stream request, %v", err) } @@ -513,15 +513,15 @@ func (c *client) StreamBuild(ctx context.Context) error { for { select { case req := <-c.streamRequests: - logs.Go(func() error { + streams.Go(func() error { // update engine logger with step metadata // // https://pkg.go.dev/github.com/sirupsen/logrus?tab=doc#Entry.WithField logger := c.Logger.WithField(req.Key, req.Container.Name) - logger.Debugf("streaming logs for %s container %s", req.Key, req.Container.ID) - // stream logs from container - err := req.Stream(logCtx, req.Container) + logger.Debugf("streaming %s container %s", req.Key, req.Container.ID) + + err := req.Stream(streamCtx, req.Container) if err != nil { logger.Error(err) } diff --git a/executor/local/build.go b/executor/local/build.go index 4f305965..c079787b 100644 --- a/executor/local/build.go +++ b/executor/local/build.go @@ -350,12 +350,12 @@ func (c *client) StreamBuild(ctx context.Context) error { // create an error group with the parent context // // https://pkg.go.dev/golang.org/x/sync/errgroup?tab=doc#WithContext - logs, logCtx := errgroup.WithContext(ctx) + streams, streamCtx := errgroup.WithContext(ctx) defer func() { fmt.Fprintln(os.Stdout, "waiting for stream functions to return") - err := logs.Wait() + err := streams.Wait() if err != nil { fmt.Fprintln(os.Stdout, "error in a stream request:", err) } @@ -366,12 +366,12 @@ func (c *client) StreamBuild(ctx context.Context) error { for { select { case req := <-c.streamRequests: - logs.Go(func() error { - fmt.Fprintf(os.Stdout, "streaming logs for %s container %s", req.Key, req.Container.ID) - // stream logs from container - err := req.Stream(logCtx, req.Container) + streams.Go(func() error { + fmt.Fprintf(os.Stdout, "streaming %s container %s", req.Key, req.Container.ID) + + err := req.Stream(streamCtx, req.Container) if err != nil { - fmt.Fprintln(os.Stdout, "error streaming logs:", err) + fmt.Fprintln(os.Stdout, "error streaming:", err) } return nil