Skip to content

Commit 43df27e

Browse files
committed
feat: app slugs pt.2
1 parent e6ddf3c commit 43df27e

File tree

25 files changed

+313
-283
lines changed

25 files changed

+313
-283
lines changed

coderd/coderdtest/authorize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ func NewAuthTester(ctx context.Context, t *testing.T, client *codersdk.Client, a
330330
Id: "something",
331331
Auth: &proto.Agent_Token{},
332332
Apps: []*proto.App{{
333-
Slug: "testapp",
334-
Name: "testapp",
335-
Url: "http://localhost:3000",
333+
Slug: "testapp",
334+
DisplayName: "testapp",
335+
Url: "http://localhost:3000",
336336
}},
337337
}},
338338
}},

coderd/provisionerdaemons.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,14 +808,11 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
808808

809809
for _, app := range prAgent.Apps {
810810
slug := app.Slug
811-
if slug == "" {
812-
slug = app.Name
813-
}
814811
if slug == "" {
815812
return xerrors.Errorf("app must have a slug or name set")
816813
}
817-
if !provisioner.ValidAppSlugRegex.MatchString(slug) {
818-
return xerrors.Errorf("app slug %q does not match regex %q", slug, provisioner.ValidAppSlugRegex.String())
814+
if !provisioner.AppSlugRegex.MatchString(slug) {
815+
return xerrors.Errorf("app slug %q does not match regex %q", slug, provisioner.AppSlugRegex.String())
819816
}
820817

821818
health := database.WorkspaceAppHealthDisabled
@@ -839,7 +836,7 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
839836
CreatedAt: database.Now(),
840837
AgentID: dbAgent.ID,
841838
Slug: slug,
842-
Name: app.Name,
839+
Name: app.DisplayName,
843840
Icon: app.Icon,
844841
Command: sql.NullString{
845842
String: app.Command,

coderd/workspaceagents_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ func TestWorkspaceAgentListeningPorts(t *testing.T) {
553553
// should not exist in the response.
554554
_, appLPort := generateUnfilteredPort(t)
555555
app := &proto.App{
556-
Slug: "test-app",
557-
Name: "test-app",
558-
Url: fmt.Sprintf("http://localhost:%d", appLPort),
556+
Slug: "test-app",
557+
DisplayName: "test-app",
558+
Url: fmt.Sprintf("http://localhost:%d", appLPort),
559559
}
560560

561561
// Generate a filtered port that should not exist in the response.
@@ -622,18 +622,18 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
622622
authToken := uuid.NewString()
623623
apps := []*proto.App{
624624
{
625-
Slug: "code-server",
626-
Name: "code-server",
627-
Command: "some-command",
628-
Url: "http://localhost:3000",
629-
Icon: "/code.svg",
625+
Slug: "code-server",
626+
DisplayName: "code-server",
627+
Command: "some-command",
628+
Url: "http://localhost:3000",
629+
Icon: "/code.svg",
630630
},
631631
{
632-
Slug: "code-server-2",
633-
Name: "code-server-2",
634-
Command: "some-command",
635-
Url: "http://localhost:3000",
636-
Icon: "/code.svg",
632+
Slug: "code-server-2",
633+
DisplayName: "code-server-2",
634+
Command: "some-command",
635+
Url: "http://localhost:3000",
636+
Icon: "/code.svg",
637637
Healthcheck: &proto.Healthcheck{
638638
Url: "http://localhost:3000",
639639
Interval: 5,

coderd/workspaceapps_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,26 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
150150
Apps: []*proto.App{
151151
{
152152
Slug: proxyTestAppNameFake,
153-
Name: proxyTestAppNameFake,
153+
DisplayName: proxyTestAppNameFake,
154154
SharingLevel: proto.AppSharingLevel_OWNER,
155155
// Hopefully this IP and port doesn't exist.
156156
Url: "http://127.1.0.1:65535",
157157
},
158158
{
159159
Slug: proxyTestAppNameOwner,
160-
Name: proxyTestAppNameOwner,
160+
DisplayName: proxyTestAppNameOwner,
161161
SharingLevel: proto.AppSharingLevel_OWNER,
162162
Url: appURL,
163163
},
164164
{
165165
Slug: proxyTestAppNameAuthenticated,
166-
Name: proxyTestAppNameAuthenticated,
166+
DisplayName: proxyTestAppNameAuthenticated,
167167
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
168168
Url: appURL,
169169
},
170170
{
171171
Slug: proxyTestAppNamePublic,
172-
Name: proxyTestAppNamePublic,
172+
DisplayName: proxyTestAppNamePublic,
173173
SharingLevel: proto.AppSharingLevel_PUBLIC,
174174
Url: appURL,
175175
},

coderd/workspaces_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,18 +1408,18 @@ func TestWorkspaceResource(t *testing.T) {
14081408
user := coderdtest.CreateFirstUser(t, client)
14091409
apps := []*proto.App{
14101410
{
1411-
Slug: "code-server",
1412-
Name: "code-server",
1413-
Command: "some-command",
1414-
Url: "http://localhost:3000",
1415-
Icon: "/code.svg",
1411+
Slug: "code-server",
1412+
DisplayName: "code-server",
1413+
Command: "some-command",
1414+
Url: "http://localhost:3000",
1415+
Icon: "/code.svg",
14161416
},
14171417
{
1418-
Slug: "code-server-2",
1419-
Name: "code-server-2",
1420-
Command: "some-command",
1421-
Url: "http://localhost:3000",
1422-
Icon: "/code.svg",
1418+
Slug: "code-server-2",
1419+
DisplayName: "code-server-2",
1420+
Command: "some-command",
1421+
Url: "http://localhost:3000",
1422+
Icon: "/code.svg",
14231423
Healthcheck: &proto.Healthcheck{
14241424
Url: "http://localhost:3000",
14251425
Interval: 5,
@@ -1462,7 +1462,7 @@ func TestWorkspaceResource(t *testing.T) {
14621462
app := apps[0]
14631463
require.EqualValues(t, app.Command, got.Command)
14641464
require.EqualValues(t, app.Icon, got.Icon)
1465-
require.EqualValues(t, app.Name, got.Name)
1465+
require.EqualValues(t, app.DisplayName, got.Name)
14661466
require.EqualValues(t, codersdk.WorkspaceAppHealthDisabled, got.Health)
14671467
require.EqualValues(t, "", got.Healthcheck.URL)
14681468
require.EqualValues(t, 0, got.Healthcheck.Interval)
@@ -1471,7 +1471,7 @@ func TestWorkspaceResource(t *testing.T) {
14711471
app = apps[1]
14721472
require.EqualValues(t, app.Command, got.Command)
14731473
require.EqualValues(t, app.Icon, got.Icon)
1474-
require.EqualValues(t, app.Name, got.Name)
1474+
require.EqualValues(t, app.DisplayName, got.Name)
14751475
require.EqualValues(t, codersdk.WorkspaceAppHealthInitializing, got.Health)
14761476
require.EqualValues(t, app.Healthcheck.Url, got.Healthcheck.URL)
14771477
require.EqualValues(t, app.Healthcheck.Interval, got.Healthcheck.Interval)

docs/ides/web-ides.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ be used as a Coder application. For example:
1919
# Note: Portainer must be already running in the workspace
2020
resource "coder_app" "portainer" {
2121
agent_id = coder_agent.main.id
22-
name = "portainer"
22+
slug = "portainer"
23+
display_name = "Portainer"
2324
icon = "https://simpleicons.org/icons/portainer.svg"
2425
url = "https://localhost:9443/api/status"
2526
@@ -75,10 +76,11 @@ You'll also need to specify a `coder_app` resource related to the agent. This is
7576

7677
```hcl
7778
resource "coder_app" "code-server" {
78-
agent_id = coder_agent.main.id
79-
name = "code-server"
80-
url = "http://localhost:13337/?folder=/home/coder"
81-
icon = "/icon/code.svg"
79+
agent_id = coder_agent.main.id
80+
slug = "code-server"
81+
display_name = "code-server"
82+
url = "http://localhost:13337/?folder=/home/coder"
83+
icon = "/icon/code.svg"
8284
8385
healthcheck {
8486
url = "http://localhost:13337/healthz"
@@ -179,10 +181,11 @@ EOT
179181
}
180182
181183
resource "coder_app" "intellij" {
182-
agent_id = coder_agent.coder.id
183-
name = "${var.jetbrains-ide}"
184-
icon = "/icon/intellij.svg"
185-
url = "http://localhost:8997/"
184+
agent_id = coder_agent.coder.id
185+
slug = "intellij"
186+
display_name = "${var.jetbrains-ide}"
187+
icon = "/icon/intellij.svg"
188+
url = "http://localhost:8997/"
186189
187190
healthcheck {
188191
url = "http://localhost:8997/"
@@ -235,10 +238,11 @@ EOF
235238
}
236239
237240
resource "coder_app" "jupyter" {
238-
agent_id = coder_agent.coder.id
239-
name = "JupyterLab"
240-
url = "http://localhost:8888${local.jupyter_base_path}"
241-
icon = "/icon/jupyter.svg"
241+
agent_id = coder_agent.coder.id
242+
slug = "jupyter"
243+
displaY_name = "JupyterLab"
244+
url = "http://localhost:8888${local.jupyter_base_path}"
245+
icon = "/icon/jupyter.svg"
242246
243247
healthcheck {
244248
url = "http://localhost:8888${local.jupyter_base_path}"

dogfood/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ resource "coder_agent" "dev" {
3838
}
3939

4040
resource "coder_app" "code-server" {
41-
agent_id = coder_agent.dev.id
42-
name = "code-server"
43-
url = "http://localhost:13337/"
44-
icon = "/icon/code.svg"
45-
subdomain = false
46-
share = "owner"
41+
agent_id = coder_agent.dev.id
42+
slug = "code-server"
43+
display_name = "code-server"
44+
url = "http://localhost:13337/"
45+
icon = "/icon/code.svg"
46+
subdomain = false
47+
share = "owner"
4748

4849
healthcheck {
4950
url = "http://localhost:13337/healthz"

enterprise/coderd/workspaceagents_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ func setupWorkspaceAgent(t *testing.T, client *codersdk.Client, user codersdk.Cr
8484
Apps: []*proto.App{
8585
{
8686
Slug: testAppNameOwner,
87-
Name: testAppNameOwner,
87+
DisplayName: testAppNameOwner,
8888
SharingLevel: proto.AppSharingLevel_OWNER,
8989
Url: fmt.Sprintf("http://localhost:%d", appPort),
9090
},
9191
{
9292
Slug: testAppNameAuthenticated,
93-
Name: testAppNameAuthenticated,
93+
DisplayName: testAppNameAuthenticated,
9494
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
9595
Url: fmt.Sprintf("http://localhost:%d", appPort),
9696
},
9797
{
9898
Slug: testAppNamePublic,
99-
Name: testAppNamePublic,
99+
DisplayName: testAppNamePublic,
100100
SharingLevel: proto.AppSharingLevel_PUBLIC,
101101
Url: fmt.Sprintf("http://localhost:%d", appPort),
102102
},

examples/templates/aws-ecs-container/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ resource "coder_agent" "coder" {
105105
}
106106

107107
resource "coder_app" "code-server" {
108-
agent_id = coder_agent.coder.id
109-
name = "code-server"
110-
icon = "/icon/code.svg"
111-
url = "http://localhost:13337?folder=/home/coder"
112-
subdomain = false
113-
share = "owner"
108+
agent_id = coder_agent.coder.id
109+
slug = "code-server"
110+
display_name = "code-server"
111+
icon = "/icon/code.svg"
112+
url = "http://localhost:13337?folder=/home/coder"
113+
subdomain = false
114+
share = "owner"
114115

115116
healthcheck {
116117
url = "http://localhost:13337/healthz"

examples/templates/aws-linux/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ resource "coder_agent" "main" {
8686
}
8787

8888
resource "coder_app" "code-server" {
89-
agent_id = coder_agent.main.id
90-
name = "code-server"
91-
url = "http://localhost:13337/?folder=/home/coder"
92-
icon = "/icon/code.svg"
93-
subdomain = false
94-
share = "owner"
89+
agent_id = coder_agent.main.id
90+
slug = "code-server"
91+
display_name = "code-server"
92+
url = "http://localhost:13337/?folder=/home/coder"
93+
icon = "/icon/code.svg"
94+
subdomain = false
95+
share = "owner"
9596

9697
healthcheck {
9798
url = "http://localhost:13337/healthz"

examples/templates/bare/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ resource "null_resource" "fake-disk" {
4343

4444
resource "coder_app" "fake-app" {
4545
# Access :8080 in the workspace from the Coder dashboard.
46-
name = "VS Code"
47-
icon = "/icon/code.svg"
48-
agent_id = "fake-compute"
49-
url = "http://localhost:8080"
50-
subdomain = false
51-
share = "owner"
46+
slug = "fake-app"
47+
display_name = "VS Code"
48+
icon = "/icon/code.svg"
49+
agent_id = "fake-compute"
50+
url = "http://localhost:8080"
51+
subdomain = false
52+
share = "owner"
5253

5354
healthcheck {
5455
url = "http://localhost:8080/healthz"

examples/templates/docker-code-server/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ resource "coder_agent" "main" {
3838
}
3939

4040
resource "coder_app" "code-server" {
41-
agent_id = coder_agent.main.id
42-
name = "code-server"
43-
url = "http://localhost:8080/?folder=/home/coder"
44-
icon = "/icon/code.svg"
45-
subdomain = false
46-
share = "owner"
41+
agent_id = coder_agent.main.id
42+
slug = "code-server"
43+
display_name = "code-server"
44+
url = "http://localhost:8080/?folder=/home/coder"
45+
icon = "/icon/code.svg"
46+
subdomain = false
47+
share = "owner"
4748

4849
healthcheck {
4950
url = "http://localhost:8080/healthz"

examples/templates/docker-image-builds/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ resource "coder_agent" "main" {
3434
}
3535

3636
resource "coder_app" "code-server" {
37-
agent_id = coder_agent.main.id
38-
name = "code-server"
39-
url = "http://localhost:13337/?folder=/home/coder"
40-
icon = "/icon/code.svg"
41-
subdomain = false
42-
share = "owner"
37+
agent_id = coder_agent.main.id
38+
slug = "code-server"
39+
display_name = "code-server"
40+
url = "http://localhost:13337/?folder=/home/coder"
41+
icon = "/icon/code.svg"
42+
subdomain = false
43+
share = "owner"
4344

4445
healthcheck {
4546
url = "http://localhost:13337/healthz"

examples/templates/docker/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ resource "coder_agent" "main" {
4343
}
4444

4545
resource "coder_app" "code-server" {
46-
agent_id = coder_agent.main.id
47-
name = "code-server"
48-
url = "http://localhost:13337/?folder=/home/coder"
49-
icon = "/icon/code.svg"
50-
subdomain = false
51-
share = "owner"
46+
agent_id = coder_agent.main.id
47+
slug = "code-server"
48+
display_name = "code-server"
49+
url = "http://localhost:13337/?folder=/home/coder"
50+
icon = "/icon/code.svg"
51+
subdomain = false
52+
share = "owner"
5253

5354
healthcheck {
5455
url = "http://localhost:13337/healthz"

examples/templates/gcp-linux/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ resource "coder_agent" "main" {
6060

6161
# code-server
6262
resource "coder_app" "code-server" {
63-
agent_id = coder_agent.main.id
64-
name = "code-server"
65-
icon = "/icon/code.svg"
66-
url = "http://localhost:13337?folder=/home/coder"
67-
subdomain = false
68-
share = "owner"
63+
agent_id = coder_agent.main.id
64+
slug = "code-server"
65+
display_name = "code-server"
66+
icon = "/icon/code.svg"
67+
url = "http://localhost:13337?folder=/home/coder"
68+
subdomain = false
69+
share = "owner"
6970

7071
healthcheck {
7172
url = "http://localhost:13337/healthz"

0 commit comments

Comments
 (0)