Skip to content

Commit

Permalink
Revert "fix: port forward function channels (#308)" (#326)
Browse files Browse the repository at this point in the history
This reverts commit 6ad89fb.
  • Loading branch information
tty47 authored May 8, 2024
1 parent 9a8b445 commit 2d5896f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pkg/k8s/k8s_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"path/filepath"
"strings"
Expand Down Expand Up @@ -265,29 +266,27 @@ func (c *Client) PortForwardPod(

stopChan := make(chan struct{}, 1)
readyChan := make(chan struct{})
defer func() {
close(stopChan)
close(readyChan)
}()

var stdout, stderr bytes.Buffer
var stdout, stderr io.Writer
// Create a new PortForwarder
pf, err := portforward.New(dialer, ports, stopChan, readyChan, &stdout, &stderr)
pf, err := portforward.New(dialer, ports, stopChan, readyChan, stdout, stderr)
if err != nil {
return ErrCreatingPortForwarder.Wrap(err)
}
if stderr.Len() > 0 {
return ErrPortForwarding.WithParams(stderr.String())
if stderr != nil {
return ErrPortForwarding.WithParams(stderr)
}
logrus.Debugf("Port forwarding from %d to %d", localPort, remotePort)
logrus.Debugf("Port forwarding stdout: %v", stdout)

// Start the port forwarding
errChan := make(chan error)
defer close(errChan)

// Start the port forwarding
go func() {
if err := pf.ForwardPorts(); err != nil {
errChan <- err
} else {
close(errChan) // if there's no error, close the channel
}
}()

Expand Down

0 comments on commit 2d5896f

Please sign in to comment.