Remove function return
This commit is contained in:
parent
4452f37819
commit
3216d1bb3a
5 changed files with 13 additions and 13 deletions
|
|
@ -62,7 +62,7 @@ func (a *App) StopProgressIndicator() {
|
|||
}
|
||||
|
||||
// Connects to a codespace using Live Share and returns that session along with a function to end it
|
||||
func startLiveShareSession(ctx context.Context, codespace *api.Codespace, a *App, debug bool, debugFile string) (*liveshare.Session, func(*error), error) {
|
||||
func startLiveShareSession(ctx context.Context, codespace *api.Codespace, a *App, debug bool, debugFile string) (*liveshare.Session, error) {
|
||||
// While connecting, ensure in the background that the user has keys installed.
|
||||
// That lets us report a more useful error message if they don't.
|
||||
authkeys := make(chan error, 1)
|
||||
|
|
@ -74,7 +74,7 @@ func startLiveShareSession(ctx context.Context, codespace *api.Codespace, a *App
|
|||
if debug {
|
||||
debugLogger, err := newFileLogger(debugFile)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
defer safeClose(debugLogger, &err)
|
||||
|
||||
|
|
@ -85,11 +85,11 @@ func startLiveShareSession(ctx context.Context, codespace *api.Codespace, a *App
|
|||
session, err := codespaces.ConnectToLiveshare(ctx, a, liveshareLogger, a.apiClient, codespace)
|
||||
if err != nil {
|
||||
if authErr := <-authkeys; authErr != nil {
|
||||
return nil, nil, authErr
|
||||
return nil, authErr
|
||||
}
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
return session, func(e *error) { safeClose(session, e) }, nil
|
||||
return session, nil
|
||||
}
|
||||
|
||||
//go:generate moq -fmt goimports -rm -skip-ensure -out mock_api.go . apiClient
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ func (a *App) Jupyter(ctx context.Context, codespaceName string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
session, endSession, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
session, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer endSession(&err)
|
||||
defer session.Close()
|
||||
|
||||
a.StartProgressIndicatorWithLabel("Starting JupyterLab on codespace")
|
||||
serverPort, serverUrl, err := session.StartJupyterServer(ctx)
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ func (a *App) Logs(ctx context.Context, codespaceName string, follow bool) (err
|
|||
return err
|
||||
}
|
||||
|
||||
session, endSession, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
session, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer endSession(&err)
|
||||
defer session.Close()
|
||||
|
||||
// Ensure local port is listening before client (getPostCreateOutput) connects.
|
||||
listen, err := net.Listen("tcp", "127.0.0.1:0") // arbitrary port
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ func (a *App) ListPorts(ctx context.Context, codespaceName string, exporter cmdu
|
|||
|
||||
devContainerCh := getDevContainer(ctx, a.apiClient, codespace)
|
||||
|
||||
session, endSession, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
session, err := startLiveShareSession(ctx, codespace, a, false, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer endSession(&err)
|
||||
defer session.Close()
|
||||
|
||||
a.StartProgressIndicatorWithLabel("Fetching ports")
|
||||
ports, err := session.GetSharedServers(ctx)
|
||||
|
|
|
|||
|
|
@ -121,11 +121,11 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e
|
|||
return err
|
||||
}
|
||||
|
||||
session, endSession, err := startLiveShareSession(ctx, codespace, a, opts.debug, opts.debugFile)
|
||||
session, err := startLiveShareSession(ctx, codespace, a, opts.debug, opts.debugFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer endSession(&err)
|
||||
defer session.Close()
|
||||
|
||||
a.StartProgressIndicatorWithLabel("Fetching SSH Details")
|
||||
remoteSSHServerPort, sshUser, err := session.StartSSHServer(ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue