Skip to content

Commit c658572

Browse files
committed
feat: app slugs pt.3
1 parent 43df27e commit c658572

26 files changed

+90
-84
lines changed

agent/apphealth.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, workspaceAgentApps Worksp
4141
hasHealthchecksEnabled := false
4242
health := make(map[string]codersdk.WorkspaceAppHealth, 0)
4343
for _, app := range apps {
44-
health[app.Name] = app.Health
44+
health[app.DisplayName] = app.Health
4545
if !hasHealthchecksEnabled && app.Health != codersdk.WorkspaceAppHealthDisabled {
4646
hasHealthchecksEnabled = true
4747
}
@@ -91,21 +91,21 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, workspaceAgentApps Worksp
9191
}()
9292
if err != nil {
9393
mu.Lock()
94-
if failures[app.Name] < int(app.Healthcheck.Threshold) {
94+
if failures[app.DisplayName] < int(app.Healthcheck.Threshold) {
9595
// increment the failure count and keep status the same.
9696
// we will change it when we hit the threshold.
97-
failures[app.Name]++
97+
failures[app.DisplayName]++
9898
} else {
9999
// set to unhealthy if we hit the failure threshold.
100100
// we stop incrementing at the threshold to prevent the failure value from increasing forever.
101-
health[app.Name] = codersdk.WorkspaceAppHealthUnhealthy
101+
health[app.DisplayName] = codersdk.WorkspaceAppHealthUnhealthy
102102
}
103103
mu.Unlock()
104104
} else {
105105
mu.Lock()
106106
// we only need one successful health check to be considered healthy.
107-
health[app.Name] = codersdk.WorkspaceAppHealthHealthy
108-
failures[app.Name] = 0
107+
health[app.DisplayName] = codersdk.WorkspaceAppHealthHealthy
108+
failures[app.DisplayName] = 0
109109
mu.Unlock()
110110
}
111111

agent/apphealth_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ func TestAppHealth(t *testing.T) {
2727
defer cancel()
2828
apps := []codersdk.WorkspaceApp{
2929
{
30-
Name: "app1",
30+
DisplayName: "app1",
3131
Healthcheck: codersdk.Healthcheck{},
3232
Health: codersdk.WorkspaceAppHealthDisabled,
3333
},
3434
{
35-
Name: "app2",
35+
DisplayName: "app2",
3636
Healthcheck: codersdk.Healthcheck{
3737
// URL: We don't set the URL for this test because the setup will
3838
// create a httptest server for us and set it for us.
@@ -69,7 +69,7 @@ func TestAppHealth(t *testing.T) {
6969
defer cancel()
7070
apps := []codersdk.WorkspaceApp{
7171
{
72-
Name: "app2",
72+
DisplayName: "app2",
7373
Healthcheck: codersdk.Healthcheck{
7474
// URL: We don't set the URL for this test because the setup will
7575
// create a httptest server for us and set it for us.
@@ -102,7 +102,7 @@ func TestAppHealth(t *testing.T) {
102102
defer cancel()
103103
apps := []codersdk.WorkspaceApp{
104104
{
105-
Name: "app2",
105+
DisplayName: "app2",
106106
Healthcheck: codersdk.Healthcheck{
107107
// URL: We don't set the URL for this test because the setup will
108108
// create a httptest server for us and set it for us.
@@ -137,7 +137,7 @@ func TestAppHealth(t *testing.T) {
137137
defer cancel()
138138
apps := []codersdk.WorkspaceApp{
139139
{
140-
Name: "app2",
140+
DisplayName: "app2",
141141
Healthcheck: codersdk.Healthcheck{
142142
// URL: We don't set the URL for this test because the setup will
143143
// create a httptest server for us and set it for us.
@@ -187,7 +187,7 @@ func setupAppReporter(ctx context.Context, t *testing.T, apps []codersdk.Workspa
187187
mu.Lock()
188188
for name, health := range req.Healths {
189189
for i, app := range apps {
190-
if app.Name != name {
190+
if app.DisplayName != name {
191191
continue
192192
}
193193
app.Health = health

coderd/database/databasefake/databasefake.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,7 @@ func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
23632363
AgentID: arg.AgentID,
23642364
CreatedAt: arg.CreatedAt,
23652365
Slug: arg.Slug,
2366-
Name: arg.Name,
2366+
DisplayName: arg.DisplayName,
23672367
Icon: arg.Icon,
23682368
Command: arg.Command,
23692369
Url: arg.Url,

coderd/database/dump.sql

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

coderd/database/migrations/000061_app_slug.up.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
BEGIN;
2+
13
-- add "slug" column to "workspace_apps" table
24
ALTER TABLE "workspace_apps" ADD COLUMN "slug" text DEFAULT '';
35

@@ -7,3 +9,5 @@ UPDATE "workspace_apps" SET "slug" = "name";
79
-- make "slug" column not nullable and remove default
810
ALTER TABLE "workspace_apps" ALTER COLUMN "slug" SET NOT NULL;
911
ALTER TABLE "workspace_apps" ALTER COLUMN "slug" DROP DEFAULT;
12+
13+
COMMIT;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- rename column "display_name" to "name" on "workspace_apps"
2+
ALTER TABLE "workspace_apps" RENAME COLUMN "display_name" TO "name";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- rename column "name" to "display_name" on "workspace_apps"
2+
ALTER TABLE "workspace_apps" RENAME COLUMN "name" TO "display_name";

coderd/database/models.go

Lines changed: 1 addition & 1 deletion
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 & 18 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ INSERT INTO
1616
id,
1717
created_at,
1818
agent_id,
19-
slug,
20-
name,
19+
slug,
20+
display_name,
2121
icon,
2222
command,
2323
url,

0 commit comments

Comments
 (0)