X Tutup
Skip to content

Commit 954d46d

Browse files
authored
Changes from comments on pr.
1 parent 0c066cb commit 954d46d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

internal/codespaces/ssh.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import (
1515
"github.com/github/go-liveshare"
1616
)
1717

18-
// MakeSSHTunnel This function initializes the liveshare tunnel
19-
// Creates the tunnel from a local port to a remote port.
20-
// Returns the local port that was used, the channel and the error if any.
2118
func MakeSSHTunnel(ctx context.Context, lsclient *liveshare.Client, localSSHPort int, remoteSSHPort int) (int, <-chan error, error) {
2219
tunnelClosed := make(chan error)
2320

@@ -48,9 +45,8 @@ func MakeSSHTunnel(ctx context.Context, lsclient *liveshare.Client, localSSHPort
4845
return port, tunnelClosed, nil
4946
}
5047

51-
// StartSSHServer starts and installs the SSH server in the codespace
52-
// returns the remote port where it is running, the user to use to login
53-
// or an error if something failed.
48+
// StartSSHServer installs (if necessary) and starts the SSH in the codespace.
49+
// It returns the remote port where it is running, the user to log in with, or an error if something failed.
5450
func StartSSHServer(ctx context.Context, client *liveshare.Client) (serverPort int, user string, err error) {
5551
sshServer, err := liveshare.NewSSHServer(client)
5652
if err != nil {

internal/codespaces/states.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ func PollPostCreateStates(ctx context.Context, log logger, apiClient *api.API, u
4545
return fmt.Errorf("connect to liveshare: %v", err)
4646
}
4747

48-
tunnelPort, connClosed, err := MakeSSHTunnel(ctx, lsclient, 0, 2222)
48+
remoteSSHServerPort, _, err := StartSSHServer(ctx, lsclient)
49+
if err != nil {
50+
return fmt.Errorf("error getting ssh server details: %v", err)
51+
}
52+
53+
tunnelPort, connClosed, err := MakeSSHTunnel(ctx, lsclient, 0, remoteSSHServerPort)
4954
if err != nil {
5055
return fmt.Errorf("make ssh tunnel: %v", err)
5156
}

0 commit comments

Comments
 (0)
X Tutup