Skip to content

Commit 342cbb0

Browse files
committed
fix insert
1 parent 66a6146 commit 342cbb0

File tree

6 files changed

+59
-25
lines changed

6 files changed

+59
-25
lines changed

coderd/database/databasefake/databasefake.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,14 +2019,18 @@ func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
20192019

20202020
// nolint:gosimple
20212021
workspaceApp := database.WorkspaceApp{
2022-
ID: arg.ID,
2023-
AgentID: arg.AgentID,
2024-
CreatedAt: arg.CreatedAt,
2025-
Name: arg.Name,
2026-
Icon: arg.Icon,
2027-
Command: arg.Command,
2028-
Url: arg.Url,
2029-
RelativePath: arg.RelativePath,
2022+
ID: arg.ID,
2023+
AgentID: arg.AgentID,
2024+
CreatedAt: arg.CreatedAt,
2025+
Name: arg.Name,
2026+
Icon: arg.Icon,
2027+
Command: arg.Command,
2028+
Url: arg.Url,
2029+
RelativePath: arg.RelativePath,
2030+
HealthcheckEnabled: arg.HealthcheckEnabled,
2031+
HealthcheckPeriod: arg.HealthcheckPeriod,
2032+
HealthcheckThreshold: arg.HealthcheckThreshold,
2033+
Health: arg.Health,
20302034
}
20312035
q.workspaceApps = append(q.workspaceApps, workspaceApp)
20322036
return workspaceApp, nil

coderd/database/queries.sql.go

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

coderd/database/queries/workspaceapps.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ INSERT INTO
2020
icon,
2121
command,
2222
url,
23-
relative_path
23+
relative_path,
24+
healthcheck_enabled,
25+
healthcheck_period,
26+
healthcheck_threshold,
27+
health
2428
)
2529
VALUES
26-
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
30+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *;
2731

2832
-- name: UpdateWorkspaceAppHealthByID :exec
2933
UPDATE

coderd/provisionerdaemons.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,11 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
826826
String: app.Url,
827827
Valid: app.Url != "",
828828
},
829-
RelativePath: app.RelativePath,
829+
RelativePath: app.RelativePath,
830+
HealthcheckEnabled: false,
831+
HealthcheckPeriod: 0,
832+
HealthcheckThreshold: 0,
833+
Health: database.WorkspaceAppHealthDisabled,
830834
})
831835
if err != nil {
832836
return xerrors.Errorf("insert app: %w", err)

coderd/workspaceagents.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,14 @@ func convertApps(dbApps []database.WorkspaceApp) []codersdk.WorkspaceApp {
435435
apps := make([]codersdk.WorkspaceApp, 0)
436436
for _, dbApp := range dbApps {
437437
apps = append(apps, codersdk.WorkspaceApp{
438-
ID: dbApp.ID,
439-
Name: dbApp.Name,
440-
Command: dbApp.Command.String,
441-
Icon: dbApp.Icon,
438+
ID: dbApp.ID,
439+
Name: dbApp.Name,
440+
Command: dbApp.Command.String,
441+
Icon: dbApp.Icon,
442+
HealthcheckEnabled: dbApp.HealthcheckEnabled,
443+
HealthcheckPeriod: dbApp.HealthcheckPeriod,
444+
HealthcheckThreshold: dbApp.HealthcheckThreshold,
445+
Health: codersdk.WorkspaceAppHealth(dbApp.Health),
442446
})
443447
}
444448
return apps

coderd/workspaceresources_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ func TestWorkspaceResource(t *testing.T) {
117117
require.Equal(t, app.Command, got.Command)
118118
require.Equal(t, app.Icon, got.Icon)
119119
require.Equal(t, app.Name, got.Name)
120+
121+
// ensure these are returned as disabled until we enable on the terraform side
122+
require.EqualValues(t, codersdk.WorkspaceAppHealthDisabled, got.Health)
123+
require.EqualValues(t, false, got.HealthcheckEnabled)
124+
require.EqualValues(t, 0, got.HealthcheckPeriod)
125+
require.EqualValues(t, 0, got.HealthcheckThreshold)
120126
})
121127

122128
t.Run("Metadata", func(t *testing.T) {

0 commit comments

Comments
 (0)