mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: refactor instance identity to be a SessionTokenProvider (#19566)
Refactors Agent instance identity to be a SessionTokenProvider. Refactors the CLI to create Agent clients via a centralized function, rather than add-hoc via individual command handlers and their flags. This allows commands besides `coder agent`, but which still use the agent identity, to support instance identity authentication. Fixes #19111 by unifying all API requests to go thru the SessionTokenProvider for auth credentials.
This commit is contained in:
@@ -68,8 +68,7 @@ func TestWorkspaceAgentReportStats(t *testing.T) {
|
||||
},
|
||||
).Do()
|
||||
|
||||
ac := agentsdk.New(client.URL)
|
||||
ac.SetSessionToken(r.AgentToken)
|
||||
ac := agentsdk.New(client.URL, agentsdk.WithFixedToken(r.AgentToken))
|
||||
conn, err := ac.ConnectRPC(context.Background())
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
@@ -155,8 +154,7 @@ func TestAgentAPI_LargeManifest(t *testing.T) {
|
||||
agents[0].ApiKeyScope = string(tc.apiKeyScope)
|
||||
return agents
|
||||
}).Do()
|
||||
ac := agentsdk.New(client.URL)
|
||||
ac.SetSessionToken(r.AgentToken)
|
||||
ac := agentsdk.New(client.URL, agentsdk.WithFixedToken(r.AgentToken))
|
||||
conn, err := ac.ConnectRPC(ctx)
|
||||
defer func() {
|
||||
_ = conn.Close()
|
||||
|
||||
Reference in New Issue
Block a user