Skip to content

Commit

Permalink
chore: refactor exec.Stream to exec.StreamWithContext
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Berlee <[email protected]>
  • Loading branch information
nberlee committed Jul 10, 2024
1 parent d03d888 commit 017e21d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pkg/devspace/build/builder/localregistry/execconn.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package localregistry

import (
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
"github.com/sirupsen/logrus"
"io"
"net"
"sync"
"time"

devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
"github.com/sirupsen/logrus"

corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand"
Expand Down Expand Up @@ -44,7 +45,7 @@ func ExecConn(ctx devspacecontext.Context, namespace, pod, container string, cmd
writer := ctx.Log().Writer(logrus.ErrorLevel, true)
defer writer.Close()

serr := exec.Stream(remotecommand.StreamOptions{
serr := exec.StreamWithContext(ctx.Context(), remotecommand.StreamOptions{
Stdin: stdinR,
Stdout: stdoutW,
Stderr: writer,
Expand Down
5 changes: 3 additions & 2 deletions pkg/devspace/kubectl/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package kubectl
import (
"bytes"
"context"
"github.com/loft-sh/devspace/pkg/util/terminal"
"io"

"github.com/loft-sh/devspace/pkg/util/terminal"
"k8s.io/kubectl/pkg/util/term"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -106,7 +107,7 @@ func (client *client) execStreamWithTransport(ctx context.Context, options *Exec
errChan := make(chan error)
go func() {
errChan <- t.Safe(func() error {
return exec.Stream(streamOptions)
return exec.StreamWithContext(ctx, streamOptions)
})
}()

Expand Down

0 comments on commit 017e21d

Please sign in to comment.