PR changes.
This commit is contained in:
parent
d5a26e1536
commit
5db9e2d83e
4 changed files with 92 additions and 18 deletions
|
|
@ -118,27 +118,30 @@ func ConnectToLiveshare(ctx context.Context, log logger, apiClient *api.API, tok
|
|||
return lsclient, nil
|
||||
}
|
||||
|
||||
func StartSSHServer(ctx context.Context, client *liveshare.Client) (result bool, serverPort int, user string, message string, err error) {
|
||||
// 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.
|
||||
func StartSSHServer(ctx context.Context, client *liveshare.Client) (serverPort int, user string, err error) {
|
||||
sshServer, err := liveshare.NewSSHServer(client)
|
||||
if err != nil {
|
||||
return false, 0, "", "", fmt.Errorf("error creating live share: %v", err)
|
||||
return 0, "", fmt.Errorf("error creating live share: %v", err)
|
||||
}
|
||||
|
||||
sshServerStartResult, err := sshServer.StartRemoteServer(ctx)
|
||||
if err != nil {
|
||||
return false, 0, "", "", fmt.Errorf("error creating live share: %v", err)
|
||||
return 0, "", fmt.Errorf("error starting live share: %v", err)
|
||||
}
|
||||
|
||||
if !sshServerStartResult.Result {
|
||||
return false, 0, "", sshServerStartResult.Message, nil
|
||||
return 0, "", errors.New(sshServerStartResult.Message)
|
||||
}
|
||||
|
||||
portInt, err := strconv.Atoi(sshServerStartResult.ServerPort)
|
||||
if err != nil {
|
||||
return false, 0, "", "", fmt.Errorf("error parsing port: %v", err)
|
||||
return 0, "", fmt.Errorf("error parsing port: %v", err)
|
||||
}
|
||||
|
||||
return sshServerStartResult.Result, portInt, sshServerStartResult.User, sshServerStartResult.Message, err
|
||||
return portInt, sshServerStartResult.User, nil
|
||||
}
|
||||
|
||||
func GetOrChooseCodespace(ctx context.Context, apiClient *api.API, user *api.User, codespaceName string) (codespace *api.Codespace, token string, err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue