Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cli/exp_scaletest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,10 @@ func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Command {
return xerrors.Errorf("parse workspace proxy URL: %w", err)
}

webClient = codersdk.New(u)
webClient.HTTPClient = client.HTTPClient
webClient.SetSessionToken(client.SessionToken())
webClient = codersdk.NewClientBuilder(u).
HTTPClient(client.HTTPClient).
SessionToken(client.SessionToken()).
Build()

appConfig, err = createWorkspaceAppConfig(webClient, appHost.Host, app, ws, agent)
if err != nil {
Expand Down Expand Up @@ -1250,8 +1251,9 @@ func (r *RootCmd) scaletestDashboard() *serpent.Command {
return xerrors.Errorf("create token for user: %w", err)
}

userClient := codersdk.New(client.URL)
userClient.SetSessionToken(userTokResp.Key)
userClient := codersdk.NewClientBuilder(client.URL).
SessionToken(userTokResp.Key).
Build()

config := dashboard.Config{
Interval: interval,
Expand Down
2 changes: 1 addition & 1 deletion cli/exp_task_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func TestTaskCreate(t *testing.T) {
var (
ctx = testutil.Context(t, testutil.WaitShort)
srv = httptest.NewServer(tt.handler(t, ctx))
client = codersdk.New(testutil.MustURL(t, srv.URL))
client = codersdk.NewClientBuilder(testutil.MustURL(t, srv.URL)).Build()
args = []string{"exp", "task", "create"}
sb strings.Builder
err error
Expand Down
2 changes: 1 addition & 1 deletion cli/exp_task_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestExpTaskDelete(t *testing.T) {
srv := httptest.NewServer(tc.buildHandler(&counters))
t.Cleanup(srv.Close)

client := codersdk.New(testutil.MustURL(t, srv.URL))
client := codersdk.NewClientBuilder(testutil.MustURL(t, srv.URL)).Build()

args := append([]string{"exp", "task", "delete"}, tc.args...)
inv, root := clitest.New(t, args...)
Expand Down
7 changes: 4 additions & 3 deletions coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func NewWithAPI(t testing.TB, options *Options) (*codersdk.Client, io.Closer, *c
if options.IncludeProvisionerDaemon {
provisionerCloser = NewTaggedProvisionerDaemon(t, coderAPI, defaultTestDaemonName, options.ProvisionerDaemonTags, coderd.MemoryProvisionerWithVersionOverride(options.ProvisionerDaemonVersion))
}
client := codersdk.New(serverURL)
client := codersdk.NewClientBuilder(serverURL).Build()
t.Cleanup(func() {
cancelFunc()
_ = provisionerCloser.Close()
Expand Down Expand Up @@ -845,8 +845,9 @@ func createAnotherUserRetry(t testing.TB, client *codersdk.Client, organizationI
require.NoError(t, err)
}

other := codersdk.New(client.URL)
other.SetSessionToken(sessionToken)
other := codersdk.NewClientBuilder(client.URL).
SessionToken(sessionToken).
Build()
t.Cleanup(func() {
other.HTTPClient.CloseIdleConnections()
})
Expand Down
5 changes: 3 additions & 2 deletions coderd/mcp_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ func (api *API) mcpHTTPHandler() http.Handler {
})
return
}
authenticatedClient := codersdk.New(api.AccessURL)
// Extract the original session token from the request
authenticatedClient.SetSessionToken(httpmw.APITokenFromRequest(r))
authenticatedClient := codersdk.NewClientBuilder(api.AccessURL).
SessionToken(httpmw.APITokenFromRequest(r)).
Build()

toolset := MCPToolset(r.URL.Query().Get("toolset"))
// Default to standard toolset if no toolset is specified.
Expand Down
Loading