Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: app slugs pt.2
  • Loading branch information
deansheather committed Oct 18, 2022
commit 43df27e3e4f3be73eb60f5730ceff2f7acf85f66
6 changes: 3 additions & 3 deletions coderd/coderdtest/authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ func NewAuthTester(ctx context.Context, t *testing.T, client *codersdk.Client, a
Id: "something",
Auth: &proto.Agent_Token{},
Apps: []*proto.App{{
Slug: "testapp",
Name: "testapp",
Url: "http://localhost:3000",
Slug: "testapp",
DisplayName: "testapp",
Url: "http://localhost:3000",
}},
}},
}},
Expand Down
9 changes: 3 additions & 6 deletions coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,11 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.

for _, app := range prAgent.Apps {
slug := app.Slug
if slug == "" {
slug = app.Name
}
if slug == "" {
return xerrors.Errorf("app must have a slug or name set")
}
if !provisioner.ValidAppSlugRegex.MatchString(slug) {
return xerrors.Errorf("app slug %q does not match regex %q", slug, provisioner.ValidAppSlugRegex.String())
if !provisioner.AppSlugRegex.MatchString(slug) {
return xerrors.Errorf("app slug %q does not match regex %q", slug, provisioner.AppSlugRegex.String())
}

health := database.WorkspaceAppHealthDisabled
Expand All @@ -839,7 +836,7 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
CreatedAt: database.Now(),
AgentID: dbAgent.ID,
Slug: slug,
Name: app.Name,
Name: app.DisplayName,
Icon: app.Icon,
Command: sql.NullString{
String: app.Command,
Expand Down
26 changes: 13 additions & 13 deletions coderd/workspaceagents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ func TestWorkspaceAgentListeningPorts(t *testing.T) {
// should not exist in the response.
_, appLPort := generateUnfilteredPort(t)
app := &proto.App{
Slug: "test-app",
Name: "test-app",
Url: fmt.Sprintf("http://localhost:%d", appLPort),
Slug: "test-app",
DisplayName: "test-app",
Url: fmt.Sprintf("http://localhost:%d", appLPort),
}

// Generate a filtered port that should not exist in the response.
Expand Down Expand Up @@ -622,18 +622,18 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
authToken := uuid.NewString()
apps := []*proto.App{
{
Slug: "code-server",
Name: "code-server",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Slug: "code-server",
DisplayName: "code-server",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
},
{
Slug: "code-server-2",
Name: "code-server-2",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Slug: "code-server-2",
DisplayName: "code-server-2",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Healthcheck: &proto.Healthcheck{
Url: "http://localhost:3000",
Interval: 5,
Expand Down
8 changes: 4 additions & 4 deletions coderd/workspaceapps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,26 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
Apps: []*proto.App{
{
Slug: proxyTestAppNameFake,
Name: proxyTestAppNameFake,
DisplayName: proxyTestAppNameFake,
SharingLevel: proto.AppSharingLevel_OWNER,
// Hopefully this IP and port doesn't exist.
Url: "http://127.1.0.1:65535",
},
{
Slug: proxyTestAppNameOwner,
Name: proxyTestAppNameOwner,
DisplayName: proxyTestAppNameOwner,
SharingLevel: proto.AppSharingLevel_OWNER,
Url: appURL,
},
{
Slug: proxyTestAppNameAuthenticated,
Name: proxyTestAppNameAuthenticated,
DisplayName: proxyTestAppNameAuthenticated,
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
Url: appURL,
},
{
Slug: proxyTestAppNamePublic,
Name: proxyTestAppNamePublic,
DisplayName: proxyTestAppNamePublic,
SharingLevel: proto.AppSharingLevel_PUBLIC,
Url: appURL,
},
Expand Down
24 changes: 12 additions & 12 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,18 +1408,18 @@ func TestWorkspaceResource(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
apps := []*proto.App{
{
Slug: "code-server",
Name: "code-server",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Slug: "code-server",
DisplayName: "code-server",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
},
{
Slug: "code-server-2",
Name: "code-server-2",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Slug: "code-server-2",
DisplayName: "code-server-2",
Command: "some-command",
Url: "http://localhost:3000",
Icon: "/code.svg",
Healthcheck: &proto.Healthcheck{
Url: "http://localhost:3000",
Interval: 5,
Expand Down Expand Up @@ -1462,7 +1462,7 @@ func TestWorkspaceResource(t *testing.T) {
app := apps[0]
require.EqualValues(t, app.Command, got.Command)
require.EqualValues(t, app.Icon, got.Icon)
require.EqualValues(t, app.Name, got.Name)
require.EqualValues(t, app.DisplayName, got.Name)
require.EqualValues(t, codersdk.WorkspaceAppHealthDisabled, got.Health)
require.EqualValues(t, "", got.Healthcheck.URL)
require.EqualValues(t, 0, got.Healthcheck.Interval)
Expand All @@ -1471,7 +1471,7 @@ func TestWorkspaceResource(t *testing.T) {
app = apps[1]
require.EqualValues(t, app.Command, got.Command)
require.EqualValues(t, app.Icon, got.Icon)
require.EqualValues(t, app.Name, got.Name)
require.EqualValues(t, app.DisplayName, got.Name)
require.EqualValues(t, codersdk.WorkspaceAppHealthInitializing, got.Health)
require.EqualValues(t, app.Healthcheck.Url, got.Healthcheck.URL)
require.EqualValues(t, app.Healthcheck.Interval, got.Healthcheck.Interval)
Expand Down
30 changes: 17 additions & 13 deletions docs/ides/web-ides.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ be used as a Coder application. For example:
# Note: Portainer must be already running in the workspace
resource "coder_app" "portainer" {
agent_id = coder_agent.main.id
name = "portainer"
slug = "portainer"
display_name = "Portainer"
icon = "https://simpleicons.org/icons/portainer.svg"
url = "https://localhost:9443/api/status"

Expand Down Expand Up @@ -75,10 +76,11 @@ You'll also need to specify a `coder_app` resource related to the agent. This is

```hcl
resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down Expand Up @@ -179,10 +181,11 @@ EOT
}

resource "coder_app" "intellij" {
agent_id = coder_agent.coder.id
name = "${var.jetbrains-ide}"
icon = "/icon/intellij.svg"
url = "http://localhost:8997/"
agent_id = coder_agent.coder.id
slug = "intellij"
display_name = "${var.jetbrains-ide}"
icon = "/icon/intellij.svg"
url = "http://localhost:8997/"

healthcheck {
url = "http://localhost:8997/"
Expand Down Expand Up @@ -235,10 +238,11 @@ EOF
}

resource "coder_app" "jupyter" {
agent_id = coder_agent.coder.id
name = "JupyterLab"
url = "http://localhost:8888${local.jupyter_base_path}"
icon = "/icon/jupyter.svg"
agent_id = coder_agent.coder.id
slug = "jupyter"
displaY_name = "JupyterLab"
url = "http://localhost:8888${local.jupyter_base_path}"
icon = "/icon/jupyter.svg"

healthcheck {
url = "http://localhost:8888${local.jupyter_base_path}"
Expand Down
13 changes: 7 additions & 6 deletions dogfood/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ resource "coder_agent" "dev" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
name = "code-server"
url = "http://localhost:13337/"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
agent_id = coder_agent.dev.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/"
icon = "/icon/code.svg"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
6 changes: 3 additions & 3 deletions enterprise/coderd/workspaceagents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ func setupWorkspaceAgent(t *testing.T, client *codersdk.Client, user codersdk.Cr
Apps: []*proto.App{
{
Slug: testAppNameOwner,
Name: testAppNameOwner,
DisplayName: testAppNameOwner,
SharingLevel: proto.AppSharingLevel_OWNER,
Url: fmt.Sprintf("http://localhost:%d", appPort),
},
{
Slug: testAppNameAuthenticated,
Name: testAppNameAuthenticated,
DisplayName: testAppNameAuthenticated,
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
Url: fmt.Sprintf("http://localhost:%d", appPort),
},
{
Slug: testAppNamePublic,
Name: testAppNamePublic,
DisplayName: testAppNamePublic,
SharingLevel: proto.AppSharingLevel_PUBLIC,
Url: fmt.Sprintf("http://localhost:%d", appPort),
},
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/aws-ecs-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ resource "coder_agent" "coder" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.coder.id
name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false
share = "owner"
agent_id = coder_agent.coder.id
slug = "code-server"
display_name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/bare/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ resource "null_resource" "fake-disk" {

resource "coder_app" "fake-app" {
# Access :8080 in the workspace from the Coder dashboard.
name = "VS Code"
icon = "/icon/code.svg"
agent_id = "fake-compute"
url = "http://localhost:8080"
subdomain = false
share = "owner"
slug = "fake-app"
display_name = "VS Code"
icon = "/icon/code.svg"
agent_id = "fake-compute"
url = "http://localhost:8080"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:8080/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/docker-code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:8080/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:8080/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:8080/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/docker-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
13 changes: 7 additions & 6 deletions examples/templates/gcp-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ resource "coder_agent" "main" {

# code-server
resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false
share = "owner"
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false
share = "owner"

healthcheck {
url = "http://localhost:13337/healthz"
Expand Down
Loading