Skip to content

Commit 6a96530

Browse files
committed
feat: add external property to coder_app
This allows exposing applications that open an external URL.
1 parent 8969f90 commit 6a96530

File tree

15 files changed

+205
-160
lines changed

15 files changed

+205
-160
lines changed

agent/apphealth.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
3434
hasHealthchecksEnabled := false
3535
health := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
3636
for _, app := range apps {
37-
health[app.ID] = app.Health
38-
if !hasHealthchecksEnabled && app.Health != codersdk.WorkspaceAppHealthDisabled {
39-
hasHealthchecksEnabled = true
37+
if app.Health == codersdk.WorkspaceAppHealthDisabled {
38+
continue
4039
}
40+
health[app.ID] = app.Health
41+
hasHealthchecksEnabled = true
4142
}
4243

4344
// no need to run this loop if no health checks are configured.
@@ -77,7 +78,7 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
7778
return err
7879
}
7980
// successful healthcheck is a non-5XX status code
80-
res.Body.Close()
81+
_ = res.Body.Close()
8182
if res.StatusCode >= http.StatusInternalServerError {
8283
return xerrors.Errorf("error status code: %d", res.StatusCode)
8384
}

coderd/database/databasefake/databasefake.go

+1
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,7 @@ func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
27432743
Icon: arg.Icon,
27442744
Command: arg.Command,
27452745
Url: arg.Url,
2746+
External: arg.External,
27462747
Subdomain: arg.Subdomain,
27472748
SharingLevel: arg.SharingLevel,
27482749
HealthcheckUrl: arg.HealthcheckUrl,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_apps DROP COLUMN external;

coderd/database/queries.sql.go

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceapps.sql

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ INSERT INTO
2121
icon,
2222
command,
2323
url,
24+
external,
2425
subdomain,
2526
sharing_level,
2627
healthcheck_url,
@@ -29,7 +30,7 @@ INSERT INTO
2930
health
3031
)
3132
VALUES
32-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) RETURNING *;
33+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING *;
3334

3435
-- name: UpdateWorkspaceAppHealthByID :exec
3536
UPDATE

coderd/provisionerdserver/provisionerdserver.go

+1
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
952952
String: app.Url,
953953
Valid: app.Url != "",
954954
},
955+
External: app.External,
955956
Subdomain: app.Subdomain,
956957
SharingLevel: sharingLevel,
957958
HealthcheckUrl: app.Healthcheck.Url,

coderd/workspaceagents.go

+1
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ func convertApps(dbApps []database.WorkspaceApp) []codersdk.WorkspaceApp {
645645
apps = append(apps, codersdk.WorkspaceApp{
646646
ID: dbApp.ID,
647647
URL: dbApp.Url.String,
648+
External: dbApp.External,
648649
Slug: dbApp.Slug,
649650
DisplayName: dbApp.DisplayName,
650651
Command: dbApp.Command.String,

provisioner/terraform/resources.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type agentAppAttributes struct {
3838
Name string `mapstructure:"name"`
3939
Icon string `mapstructure:"icon"`
4040
URL string `mapstructure:"url"`
41+
External bool `mapstructure:"external"`
4142
Command string `mapstructure:"command"`
4243
Share string `mapstructure:"share"`
4344
Subdomain bool `mapstructure:"subdomain"`
@@ -297,6 +298,7 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
297298
Slug: attrs.Slug,
298299
DisplayName: attrs.DisplayName,
299300
Command: attrs.Command,
301+
External: attrs.External,
300302
Url: attrs.URL,
301303
Icon: attrs.Icon,
302304
Subdomain: attrs.Subdomain,

0 commit comments

Comments
 (0)