Skip to content

Commit 2f7fc2a

Browse files
committed
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.
1 parent 737dc49 commit 2f7fc2a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

executor/linux/build.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,12 @@ func (c *client) StreamBuild(ctx context.Context) error {
497497
// create an error group with the parent context
498498
//
499499
// https://pkg.go.dev/golang.org/x/sync/errgroup?tab=doc#WithContext
500-
logs, logCtx := errgroup.WithContext(ctx)
500+
streams, streamCtx := errgroup.WithContext(ctx)
501501

502502
defer func() {
503503
c.Logger.Trace("waiting for stream functions to return")
504504

505-
err := logs.Wait()
505+
err := streams.Wait()
506506
if err != nil {
507507
c.Logger.Errorf("error in a stream request, %v", err)
508508
}
@@ -513,15 +513,15 @@ func (c *client) StreamBuild(ctx context.Context) error {
513513
for {
514514
select {
515515
case req := <-c.streamRequests:
516-
logs.Go(func() error {
516+
streams.Go(func() error {
517517
// update engine logger with step metadata
518518
//
519519
// https://pkg.go.dev/github.com/sirupsen/logrus?tab=doc#Entry.WithField
520520
logger := c.Logger.WithField(req.Key, req.Container.Name)
521521

522-
logger.Debugf("streaming logs for %s container %s", req.Key, req.Container.ID)
523-
// stream logs from container
524-
err := req.Stream(logCtx, req.Container)
522+
logger.Debugf("streaming %s container %s", req.Key, req.Container.ID)
523+
524+
err := req.Stream(streamCtx, req.Container)
525525
if err != nil {
526526
logger.Error(err)
527527
}

executor/local/build.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ func (c *client) StreamBuild(ctx context.Context) error {
350350
// create an error group with the parent context
351351
//
352352
// https://pkg.go.dev/golang.org/x/sync/errgroup?tab=doc#WithContext
353-
logs, logCtx := errgroup.WithContext(ctx)
353+
streams, streamCtx := errgroup.WithContext(ctx)
354354

355355
defer func() {
356356
fmt.Fprintln(os.Stdout, "waiting for stream functions to return")
357357

358-
err := logs.Wait()
358+
err := streams.Wait()
359359
if err != nil {
360360
fmt.Fprintln(os.Stdout, "error in a stream request:", err)
361361
}
@@ -366,12 +366,12 @@ func (c *client) StreamBuild(ctx context.Context) error {
366366
for {
367367
select {
368368
case req := <-c.streamRequests:
369-
logs.Go(func() error {
370-
fmt.Fprintf(os.Stdout, "streaming logs for %s container %s", req.Key, req.Container.ID)
371-
// stream logs from container
372-
err := req.Stream(logCtx, req.Container)
369+
streams.Go(func() error {
370+
fmt.Fprintf(os.Stdout, "streaming %s container %s", req.Key, req.Container.ID)
371+
372+
err := req.Stream(streamCtx, req.Container)
373373
if err != nil {
374-
fmt.Fprintln(os.Stdout, "error streaming logs:", err)
374+
fmt.Fprintln(os.Stdout, "error streaming:", err)
375375
}
376376

377377
return nil

0 commit comments

Comments
 (0)