Skip to content

Commit 31caacc

Browse files
committed
feat: agent APIVersion
1 parent 90573a6 commit 31caacc

File tree

16 files changed

+47
-3
lines changed

16 files changed

+47
-3
lines changed

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6308,6 +6308,7 @@ func (q *FakeQuerier) UpdateWorkspaceAgentStartupByID(_ context.Context, arg dat
63086308
}
63096309

63106310
agent.Version = arg.Version
6311+
agent.APIVersion = arg.APIVersion
63116312
agent.ExpandedDirectory = arg.ExpandedDirectory
63126313
agent.Subsystems = arg.Subsystems
63136314
q.workspaceAgents[index] = agent

coderd/database/queries.sql.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceagents.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ UPDATE
6969
SET
7070
version = $2,
7171
expanded_directory = $3,
72-
subsystems = $4
72+
subsystems = $4,
73+
api_version = $5
7374
WHERE
7475
id = $1;
7576

coderd/workspaceagents.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ func (api *API) workspaceAgentManifest(rw http.ResponseWriter, r *http.Request)
250250
})
251251
}
252252

253+
const AgentAPIVersionREST = "1.0"
254+
253255
// @Summary Submit workspace agent startup
254256
// @ID submit-workspace-agent-startup
255257
// @Security CoderSessionToken
@@ -321,6 +323,7 @@ func (api *API) postWorkspaceAgentStartup(rw http.ResponseWriter, r *http.Reques
321323
Version: req.Version,
322324
ExpandedDirectory: req.ExpandedDirectory,
323325
Subsystems: convertWorkspaceAgentSubsystems(req.Subsystems),
326+
APIVersion: AgentAPIVersionREST,
324327
}); err != nil {
325328
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
326329
Message: "Error setting agent version",
@@ -1542,6 +1545,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
15421545
LogsOverflowed: dbAgent.LogsOverflowed,
15431546
LogSources: logSources,
15441547
Version: dbAgent.Version,
1548+
APIVersion: dbAgent.APIVersion,
15451549
EnvironmentVariables: envs,
15461550
Directory: dbAgent.Directory,
15471551
ExpandedDirectory: dbAgent.ExpandedDirectory,

coderd/workspaceagents_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"cdr.dev/slog"
2222
"cdr.dev/slog/sloggers/slogtest"
2323
"github.com/coder/coder/v2/agent/agenttest"
24+
"github.com/coder/coder/v2/coderd"
2425
"github.com/coder/coder/v2/coderd/coderdtest"
2526
"github.com/coder/coder/v2/coderd/database"
2627
"github.com/coder/coder/v2/coderd/database/dbtime"
@@ -1367,6 +1368,7 @@ func TestWorkspaceAgent_Startup(t *testing.T) {
13671368
require.Equal(t, expectedDir, wsagent.ExpandedDirectory)
13681369
// Sorted
13691370
require.Equal(t, expectedSubsystems, wsagent.Subsystems)
1371+
require.Equal(t, coderd.AgentAPIVersionREST, wsagent.APIVersion)
13701372
})
13711373

13721374
t.Run("InvalidSemver", func(t *testing.T) {

codersdk/deployment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func TestTimezoneOffsets(t *testing.T) {
218218
// Name: "Eastern",
219219
// Loc: must(time.LoadLocation("America/New_York")),
220220
// ExpectedOffset: -4,
221-
//},
221+
// },
222222
//{
223223
// Name: "Central",
224224
// Loc: must(time.LoadLocation("America/Chicago")),

codersdk/workspaceagents.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ type WorkspaceAgent struct {
166166
Directory string `json:"directory,omitempty"`
167167
ExpandedDirectory string `json:"expanded_directory,omitempty"`
168168
Version string `json:"version"`
169+
APIVersion string `json:"api_version"`
169170
Apps []WorkspaceApp `json:"apps"`
170171
// DERPLatency is mapped by region name (e.g. "New York City", "Seattle").
171172
DERPLatency map[string]DERPRegion `json:"latency,omitempty"`

docs/api/agents.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/builds.md

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)