Skip to content

feat: use app wildcards for apps if configured #4263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 5, 2022
2 changes: 1 addition & 1 deletion coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
Icon: arg.Icon,
Command: arg.Command,
Url: arg.Url,
RelativePath: arg.RelativePath,
Subdomain: arg.Subdomain,
HealthcheckUrl: arg.HealthcheckUrl,
HealthcheckInterval: arg.HealthcheckInterval,
HealthcheckThreshold: arg.HealthcheckThreshold,
Expand Down
4 changes: 2 additions & 2 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Add column relative_path of type bool to workspace_apps
ALTER TABLE "workspace_apps" ADD COLUMN "relative_path" bool NOT NULL DEFAULT false;

-- Set column relative_path to the opposite of subdomain
UPDATE "workspace_apps" SET "relative_path" = NOT "subdomain";

-- Drop column subdomain
ALTER TABLE "workspace_apps" DROP COLUMN "subdomain";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Add column subdomain of type bool to workspace_apps
ALTER TABLE "workspace_apps" ADD COLUMN "subdomain" bool NOT NULL DEFAULT false;

-- Set column subdomain to the opposite of relative_path
UPDATE "workspace_apps" SET "subdomain" = NOT "relative_path";

-- Drop column relative_path
ALTER TABLE "workspace_apps" DROP COLUMN "relative_path";
2 changes: 1 addition & 1 deletion coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion coderd/database/queries/workspaceapps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ INSERT INTO
icon,
command,
url,
relative_path,
subdomain,
healthcheck_url,
healthcheck_interval,
healthcheck_threshold,
Expand Down
2 changes: 1 addition & 1 deletion coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
String: app.Url,
Valid: app.Url != "",
},
RelativePath: app.RelativePath,
Subdomain: app.Subdomain,
HealthcheckUrl: app.Healthcheck.Url,
HealthcheckInterval: app.Healthcheck.Interval,
HealthcheckThreshold: app.Healthcheck.Threshold,
Expand Down
20 changes: 10 additions & 10 deletions coderd/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent {
// ConvertWorkspaceApp anonymizes a workspace app.
func ConvertWorkspaceApp(app database.WorkspaceApp) WorkspaceApp {
return WorkspaceApp{
ID: app.ID,
CreatedAt: app.CreatedAt,
AgentID: app.AgentID,
Icon: app.Icon,
RelativePath: app.RelativePath,
ID: app.ID,
CreatedAt: app.CreatedAt,
AgentID: app.AgentID,
Icon: app.Icon,
Subdomain: app.Subdomain,
}
}

Expand Down Expand Up @@ -692,11 +692,11 @@ type WorkspaceAgent struct {
}

type WorkspaceApp struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
AgentID uuid.UUID `json:"agent_id"`
Icon string `json:"icon"`
RelativePath bool `json:"relative_path"`
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
AgentID uuid.UUID `json:"agent_id"`
Icon string `json:"icon"`
Subdomain bool `json:"subdomain"`
}

type WorkspaceBuild struct {
Expand Down
9 changes: 5 additions & 4 deletions coderd/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,11 @@ func convertApps(dbApps []database.WorkspaceApp) []codersdk.WorkspaceApp {
apps := make([]codersdk.WorkspaceApp, 0)
for _, dbApp := range dbApps {
apps = append(apps, codersdk.WorkspaceApp{
ID: dbApp.ID,
Name: dbApp.Name,
Command: dbApp.Command.String,
Icon: dbApp.Icon,
ID: dbApp.ID,
Name: dbApp.Name,
Command: dbApp.Command.String,
Icon: dbApp.Icon,
Subdomain: dbApp.Subdomain,
Healthcheck: codersdk.Healthcheck{
URL: dbApp.HealthcheckUrl,
Interval: dbApp.HealthcheckInterval,
Expand Down
5 changes: 5 additions & 0 deletions codersdk/workspaceapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ type WorkspaceApp struct {
// Icon is a relative path or external URL that specifies
// an icon to be displayed in the dashboard.
Icon string `json:"icon,omitempty"`
// Subdomain denotes whether the app should be accessed via a path on the
// `coder server` or via a hostname-based dev URL. If this is set to true
// and there is no app wildcard configured on the server, the app will not
// be accessible in the UI.
Subdomain bool `json:"subdomain"`
// Healthcheck specifies the configuration for checking app health.
Healthcheck Healthcheck `json:"healthcheck"`
Health WorkspaceAppHealth `json:"health"`
Expand Down
2 changes: 1 addition & 1 deletion dogfood/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
docker = {
source = "kreuzwerker/docker"
Expand Down
12 changes: 6 additions & 6 deletions examples/templates/aws-ecs-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
}
}
Expand Down Expand Up @@ -105,11 +105,11 @@ 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"
relative_path = true
agent_id = coder_agent.coder.id
name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false

healthcheck {
url = "http://localhost:1337/healthz"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/aws-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/azure-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
azurerm = {
source = "hashicorp/azurerm"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/do-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
digitalocean = {
source = "digitalocean/digitalocean"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/docker-code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
docker = {
source = "kreuzwerker/docker"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/docker-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
docker = {
source = "kreuzwerker/docker"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/docker-with-dotfiles/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
docker = {
source = "kreuzwerker/docker"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "0.4.15"
version = "0.5.0"
}
docker = {
source = "kreuzwerker/docker"
Expand Down
Loading