Changes from comments on pr.

This commit is contained in:
Edmundo Gonzalez 2021-08-30 17:30:28 +00:00 committed by GitHub
parent 0c066cbd09
commit 954d46dce5
2 changed files with 8 additions and 7 deletions

View file

@ -15,9 +15,6 @@ import (
"github.com/github/go-liveshare"
)
// MakeSSHTunnel This function initializes the liveshare tunnel
// Creates the tunnel from a local port to a remote port.
// Returns the local port that was used, the channel and the error if any.
func MakeSSHTunnel(ctx context.Context, lsclient *liveshare.Client, localSSHPort int, remoteSSHPort int) (int, <-chan error, error) {
tunnelClosed := make(chan error)
@ -48,9 +45,8 @@ func MakeSSHTunnel(ctx context.Context, lsclient *liveshare.Client, localSSHPort
return port, tunnelClosed, nil
}
// StartSSHServer starts and installs the SSH server in the codespace
// returns the remote port where it is running, the user to use to login
// or an error if something failed.
// StartSSHServer installs (if necessary) and starts the SSH in the codespace.
// It returns the remote port where it is running, the user to log in with, or an error if something failed.
func StartSSHServer(ctx context.Context, client *liveshare.Client) (serverPort int, user string, err error) {
sshServer, err := liveshare.NewSSHServer(client)
if err != nil {

View file

@ -45,7 +45,12 @@ func PollPostCreateStates(ctx context.Context, log logger, apiClient *api.API, u
return fmt.Errorf("connect to liveshare: %v", err)
}
tunnelPort, connClosed, err := MakeSSHTunnel(ctx, lsclient, 0, 2222)
remoteSSHServerPort, _, err := StartSSHServer(ctx, lsclient)
if err != nil {
return fmt.Errorf("error getting ssh server details: %v", err)
}
tunnelPort, connClosed, err := MakeSSHTunnel(ctx, lsclient, 0, remoteSSHServerPort)
if err != nil {
return fmt.Errorf("make ssh tunnel: %v", err)
}