Skip to content

Commit b712d0b

Browse files
feat(coderd/agentapi): implement sub agent api (coder#17823)
Closes coder/internal#619 Implement the `coderd` side of the AgentAPI for the upcoming dev-container agents work. `agent/agenttest/client.go` is left unimplemented for a future PR working to implement the agent side of this feature.
1 parent bc83de2 commit b712d0b

File tree

25 files changed

+1745
-230
lines changed

25 files changed

+1745
-230
lines changed

agent/agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ type Options struct {
9595
}
9696

9797
type Client interface {
98-
ConnectRPC25(ctx context.Context) (
99-
proto.DRPCAgentClient25, tailnetproto.DRPCTailnetClient25, error,
98+
ConnectRPC26(ctx context.Context) (
99+
proto.DRPCAgentClient26, tailnetproto.DRPCTailnetClient26, error,
100100
)
101101
RewriteDERPMap(derpMap *tailcfg.DERPMap)
102102
}
@@ -908,7 +908,7 @@ func (a *agent) run() (retErr error) {
908908
a.sessionToken.Store(&sessionToken)
909909

910910
// ConnectRPC returns the dRPC connection we use for the Agent and Tailnet v2+ APIs
911-
aAPI, tAPI, err := a.client.ConnectRPC25(a.hardCtx)
911+
aAPI, tAPI, err := a.client.ConnectRPC26(a.hardCtx)
912912
if err != nil {
913913
return err
914914
}

agent/agenttest/client.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ func (c *Client) Close() {
9898
c.derpMapOnce.Do(func() { close(c.derpMapUpdates) })
9999
}
100100

101-
func (c *Client) ConnectRPC25(ctx context.Context) (
102-
agentproto.DRPCAgentClient25, proto.DRPCTailnetClient25, error,
101+
func (c *Client) ConnectRPC26(ctx context.Context) (
102+
agentproto.DRPCAgentClient26, proto.DRPCTailnetClient26, error,
103103
) {
104104
conn, lis := drpcsdk.MemTransportPipe()
105105
c.LastWorkspaceAgent = func() {
@@ -365,6 +365,18 @@ func (f *FakeAgentAPI) GetConnectionReports() []*agentproto.ReportConnectionRequ
365365
return slices.Clone(f.connectionReports)
366366
}
367367

368+
func (*FakeAgentAPI) CreateSubAgent(_ context.Context, _ *agentproto.CreateSubAgentRequest) (*agentproto.CreateSubAgentResponse, error) {
369+
panic("unimplemented")
370+
}
371+
372+
func (*FakeAgentAPI) DeleteSubAgent(_ context.Context, _ *agentproto.DeleteSubAgentRequest) (*agentproto.DeleteSubAgentResponse, error) {
373+
panic("unimplemented")
374+
}
375+
376+
func (*FakeAgentAPI) ListSubAgents(_ context.Context, _ *agentproto.ListSubAgentsRequest) (*agentproto.ListSubAgentsResponse, error) {
377+
panic("unimplemented")
378+
}
379+
368380
func NewFakeAgentAPI(t testing.TB, logger slog.Logger, manifest *agentproto.Manifest, statsCh chan *agentproto.Stats) *FakeAgentAPI {
369381
return &FakeAgentAPI{
370382
t: t,

0 commit comments

Comments
 (0)