Skip to content

Commit

Permalink
Remove unused token field
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgardiner25 committed Jan 6, 2023
1 parent 000a84d commit 814fcf8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions internal/codespaces/rpc/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ type Invoker interface {

type invoker struct {
conn *grpc.ClientConn
token string
session liveshare.LiveshareSession
listener net.Listener
jupyterClient jupyter.JupyterServerHostClient
cancelPF context.CancelFunc
}

// Connects to the internal RPC server and returns a new invoker for it
func CreateInvoker(ctx context.Context, session liveshare.LiveshareSession, token string) (Invoker, error) {
func CreateInvoker(ctx context.Context, session liveshare.LiveshareSession) (Invoker, error) {
ctx, cancel := context.WithTimeout(ctx, ConnectionTimeout)
defer cancel()

invoker, err := connect(ctx, session, token)
invoker, err := connect(ctx, session)
if err != nil {
return nil, fmt.Errorf("error connecting to internal server: %w", err)
}
Expand All @@ -58,15 +57,14 @@ func CreateInvoker(ctx context.Context, session liveshare.LiveshareSession, toke
}

// Finds a free port to listen on and creates a new RPC invoker that connects to that port
func connect(ctx context.Context, session liveshare.LiveshareSession, token string) (Invoker, error) {
func connect(ctx context.Context, session liveshare.LiveshareSession) (Invoker, error) {
listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", 0))
if err != nil {
return nil, fmt.Errorf("failed to listen to local port over tcp: %w", err)
}
localAddress := fmt.Sprintf("127.0.0.1:%d", listener.Addr().(*net.TCPAddr).Port)

invoker := &invoker{
token: token,
session: session,
listener: listener,
}
Expand Down Expand Up @@ -136,7 +134,7 @@ func (i *invoker) Close() error {

// Appends the authentication token to the gRPC context
func (i *invoker) appendMetadata(ctx context.Context) context.Context {
return metadata.AppendToOutgoingContext(ctx, "Authorization", "Bearer "+i.token)
return metadata.AppendToOutgoingContext(ctx, "Authorization", "Bearer token")
}

// Starts a remote JupyterLab server to allow the user to connect to the codespace via JupyterLab in their browser
Expand Down
2 changes: 1 addition & 1 deletion internal/codespaces/rpc/invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func startServer(t *testing.T) {
func createTestInvoker(t *testing.T) Invoker {
t.Helper()

invoker, err := CreateInvoker(context.Background(), &rpctest.Session{}, "token") //connect(context.Background(), &rpctest.Session{}, "token")
invoker, err := CreateInvoker(context.Background(), &rpctest.Session{})
if err != nil {
t.Fatalf("error connecting to internal server: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/codespaces/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func PollPostCreateStates(ctx context.Context, progress progressIndicator, apiCl
localPort := listen.Addr().(*net.TCPAddr).Port

progress.StartProgressIndicatorWithLabel("Fetching SSH Details")
invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/codespace/jupyter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a *App) Jupyter(ctx context.Context, codespaceName string) (err error) {
defer safeClose(session, &err)

a.StartProgressIndicatorWithLabel("Starting JupyterLab on codespace")
invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/codespace/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (a *App) Logs(ctx context.Context, codespaceName string, follow bool) (err
localPort := listen.Addr().(*net.TCPAddr).Port

a.StartProgressIndicatorWithLabel("Fetching SSH Details")
invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/codespace/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (a *App) Rebuild(ctx context.Context, codespaceName string, full bool) (err
}
defer safeClose(session, &err)

invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/codespace/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e
defer safeClose(session, &err)

a.StartProgressIndicatorWithLabel("Fetching SSH Details")
invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
return err
}
Expand Down Expand Up @@ -515,7 +515,7 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts sshOptions) (err erro
} else {
defer safeClose(session, &err)

invoker, err := rpc.CreateInvoker(ctx, session, "")
invoker, err := rpc.CreateInvoker(ctx, session)
if err != nil {
result.err = fmt.Errorf("error connecting to codespace: %w", err)
} else {
Expand Down

0 comments on commit 814fcf8

Please sign in to comment.