Remove function return

This commit is contained in:
JP Ungaretti 2022-04-21 14:29:30 -07:00
parent 4452f37819
commit 3216d1bb3a
5 changed files with 13 additions and 13 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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)