Skip to content

Commit 24b37d9

Browse files
committed
Working implementation
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 976cd78 commit 24b37d9

File tree

21 files changed

+232
-38
lines changed

21 files changed

+232
-38
lines changed

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/database/dump.sql

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

coderd/database/migrations/000279_template_level_cors.down.sql

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ALTER TABLE templates
2+
ADD COLUMN cors_behavior app_cors_behavior NOT NULL DEFAULT 'simple'::app_cors_behavior;
3+
4+
-- Update the template_with_users view by recreating it.
5+
DROP VIEW IF EXISTS template_with_names;
6+
CREATE VIEW template_with_names AS
7+
SELECT templates.id,
8+
templates.created_at,
9+
templates.updated_at,
10+
templates.organization_id,
11+
templates.deleted,
12+
templates.name,
13+
templates.provisioner,
14+
templates.active_version_id,
15+
templates.description,
16+
templates.default_ttl,
17+
templates.created_by,
18+
templates.icon,
19+
templates.user_acl,
20+
templates.group_acl,
21+
templates.display_name,
22+
templates.allow_user_cancel_workspace_jobs,
23+
templates.allow_user_autostart,
24+
templates.allow_user_autostop,
25+
templates.failure_ttl,
26+
templates.time_til_dormant,
27+
templates.time_til_dormant_autodelete,
28+
templates.autostop_requirement_days_of_week,
29+
templates.autostop_requirement_weeks,
30+
templates.autostart_block_days_of_week,
31+
templates.require_active_version,
32+
templates.deprecated,
33+
templates.activity_bump,
34+
templates.max_port_sharing_level,
35+
templates.cors_behavior,
36+
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
37+
COALESCE(visible_users.username, ''::text) AS created_by_username,
38+
COALESCE(organizations.name, ''::text) AS organization_name,
39+
COALESCE(organizations.display_name, ''::text) AS organization_display_name,
40+
COALESCE(organizations.icon, ''::text) AS organization_icon
41+
FROM ((templates
42+
LEFT JOIN visible_users ON ((templates.created_by = visible_users.id)))
43+
LEFT JOIN organizations ON ((templates.organization_id = organizations.id)));
44+
45+
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';

coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (q *sqlQuerier) GetAuthorizedTemplates(ctx context.Context, arg GetTemplate
117117
&i.Deprecated,
118118
&i.ActivityBump,
119119
&i.MaxPortSharingLevel,
120+
&i.CORSBehavior,
120121
&i.CreatedByAvatarURL,
121122
&i.CreatedByUsername,
122123
&i.OrganizationName,

coderd/database/models.go

Lines changed: 2 additions & 0 deletions
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 & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/templates.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ INSERT INTO
9090
group_acl,
9191
display_name,
9292
allow_user_cancel_workspace_jobs,
93-
max_port_sharing_level
93+
max_port_sharing_level,
94+
cors_behavior
9495
)
9596
VALUES
96-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);
97+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16);
9798

9899
-- name: UpdateTemplateActiveVersionByID :exec
99100
UPDATE
@@ -124,7 +125,8 @@ SET
124125
display_name = $6,
125126
allow_user_cancel_workspace_jobs = $7,
126127
group_acl = $8,
127-
max_port_sharing_level = $9
128+
max_port_sharing_level = $9,
129+
cors_behavior = $10
128130
WHERE
129131
id = $1
130132
;

0 commit comments

Comments
 (0)