Skip to content

Commit e918531

Browse files
committed
feat: add default_apps field to agent
1 parent 4e36f91 commit e918531

22 files changed

+417
-236
lines changed

coderd/apidoc/docs.go

Lines changed: 23 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: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_agents DROP COLUMN default_apps;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_agents ADD column default_apps text[] DEFAULT NULL;

coderd/database/models.go

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

coderd/database/queries.sql.go

Lines changed: 18 additions & 8 deletions
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ INSERT INTO
6060
startup_script_behavior,
6161
startup_script_timeout_seconds,
6262
shutdown_script,
63-
shutdown_script_timeout_seconds
63+
shutdown_script_timeout_seconds,
64+
default_apps
6465
)
6566
VALUES
66-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21) RETURNING *;
67+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22) RETURNING *;
6768

6869
-- name: UpdateWorkspaceAgentConnectionByID :exec
6970
UPDATE

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
12121212
Valid: prAgent.ShutdownScript != "",
12131213
},
12141214
ShutdownScriptTimeoutSeconds: prAgent.GetShutdownScriptTimeoutSeconds(),
1215+
DefaultApps: prAgent.DefaultApps,
12151216
})
12161217
if err != nil {
12171218
return xerrors.Errorf("insert agent: %w", err)

coderd/workspaceagents.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
13301330
ShutdownScript: dbAgent.ShutdownScript.String,
13311331
ShutdownScriptTimeoutSeconds: dbAgent.ShutdownScriptTimeoutSeconds,
13321332
Subsystems: subsystems,
1333+
DefaultApps: convertDefaultApps(dbAgent.DefaultApps),
13331334
}
13341335
node := coordinator.Node(dbAgent.ID)
13351336
if node != nil {
@@ -1391,6 +1392,18 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
13911392
return workspaceAgent, nil
13921393
}
13931394

1395+
func convertDefaultApps(apps []string) []codersdk.DefaultApp {
1396+
dapps := make([]codersdk.DefaultApp, 0, len(apps))
1397+
for _, app := range apps {
1398+
switch codersdk.DefaultApp(app) {
1399+
case codersdk.DefaultAppVSCodeDesktop, codersdk.DefaultAppVSCodeInsiders, codersdk.DefaultAppPortForward, codersdk.DefaultAppWebTerminal:
1400+
dapps = append(dapps, codersdk.DefaultApp(app))
1401+
}
1402+
}
1403+
1404+
return dapps
1405+
}
1406+
13941407
// @Summary Submit workspace agent stats
13951408
// @ID submit-workspace-agent-stats
13961409
// @Security CoderSessionToken

codersdk/workspaceagents.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ type WorkspaceAgentMetadata struct {
133133
Description WorkspaceAgentMetadataDescription `json:"description"`
134134
}
135135

136+
type DefaultApp string
137+
138+
const (
139+
DefaultAppVSCodeDesktop DefaultApp = "vscode-desktop"
140+
DefaultAppVSCodeInsiders DefaultApp = "vscode-insiders"
141+
DefaultAppWebTerminal DefaultApp = "web-terminal"
142+
DefaultAppPortForward DefaultApp = "port-forward-helper"
143+
DefaultAppSSH DefaultApp = "ssh-helper"
144+
)
145+
136146
type WorkspaceAgent struct {
137147
ID uuid.UUID `json:"id" format:"uuid"`
138148
CreatedAt time.Time `json:"created_at" format:"date-time"`
@@ -169,6 +179,7 @@ type WorkspaceAgent struct {
169179
ShutdownScriptTimeoutSeconds int32 `json:"shutdown_script_timeout_seconds"`
170180
Subsystems []AgentSubsystem `json:"subsystems"`
171181
Health WorkspaceAgentHealth `json:"health"` // Health reports the health of the agent.
182+
DefaultApps []DefaultApp `json:"default_apps"`
172183
}
173184

174185
type WorkspaceAgentHealth struct {

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.

0 commit comments

Comments
 (0)