MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

codersdk/agentsdk/agentsdk.go:50–61  ·  view source on GitHub ↗

New creates a new *Client which can be used by an agent to connect to Coderd. Use a SessionTokenSetup function to define the session token provider for the Client. This overrides the SessionTokenProvider on the underlying `*codersdk.Client`, so any `codersdk.ClientOptions` passed as `opts` should no

(serverURL *url.URL, setup SessionTokenSetup, opts ...codersdk.ClientOption)

Source from the content-addressed store, hash-verified

48// to define the session token provider for the Client. This overrides the SessionTokenProvider on the underlying
49// `*codersdk.Client`, so any `codersdk.ClientOptions` passed as `opts` should not set this property.
50func New(serverURL *url.URL, setup SessionTokenSetup, opts ...codersdk.ClientOption) *Client {
51 var provider RefreshableSessionTokenProvider
52 opts = append(opts, func(c *codersdk.Client) {
53 provider = setup(c)
54 c.SessionTokenProvider = provider
55 })
56 c := codersdk.New(serverURL, opts...)
57 return &Client{
58 SDK: c,
59 RefreshableSessionTokenProvider: provider,
60 }
61}
62
63// Client wraps `codersdk.Client` with specific functions
64// scoped to a workspace agent.

Calls 2

NewFunction · 0.92
setupFunction · 0.50