Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2bc801

Browse files
authored
chore: add 'classic_parameter_flow' column setting to templates (#17828)
We are forcing users to try the dynamic parameter experience first. Currently this setting only comes into effect if an experiment is enabled.
1 parent 9063b67 commit c2bc801

File tree

21 files changed

+229
-45
lines changed

21 files changed

+229
-45
lines changed

coderd/apidoc/docs.go

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

coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11084,6 +11084,7 @@ func (q *FakeQuerier) UpdateTemplateMetaByID(_ context.Context, arg database.Upd
1108411084
tpl.GroupACL = arg.GroupACL
1108511085
tpl.AllowUserCancelWorkspaceJobs = arg.AllowUserCancelWorkspaceJobs
1108611086
tpl.MaxPortSharingLevel = arg.MaxPortSharingLevel
11087+
tpl.UseClassicParameterFlow = arg.UseClassicParameterFlow
1108711088
q.templates[idx] = tpl
1108811089
return nil
1108911090
}

coderd/database/dump.sql

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DROP VIEW template_with_names;
2+
3+
-- Drop the column
4+
ALTER TABLE templates DROP COLUMN use_classic_parameter_flow;
5+
6+
7+
CREATE VIEW
8+
template_with_names
9+
AS
10+
SELECT
11+
templates.*,
12+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
13+
coalesce(visible_users.username, '') AS created_by_username,
14+
coalesce(organizations.name, '') AS organization_name,
15+
coalesce(organizations.display_name, '') AS organization_display_name,
16+
coalesce(organizations.icon, '') AS organization_icon
17+
FROM
18+
templates
19+
LEFT JOIN
20+
visible_users
21+
ON
22+
templates.created_by = visible_users.id
23+
LEFT JOIN
24+
organizations
25+
ON templates.organization_id = organizations.id
26+
;
27+
28+
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- Default to `false`. Users will have to manually opt back into the classic parameter flow.
2+
-- We want the new experience to be tried first.
3+
ALTER TABLE templates ADD COLUMN use_classic_parameter_flow BOOL NOT NULL DEFAULT false;
4+
5+
COMMENT ON COLUMN templates.use_classic_parameter_flow IS
6+
'Determines whether to default to the dynamic parameter creation flow for this template '
7+
'or continue using the legacy classic parameter creation flow.'
8+
'This is a template wide setting, the template admin can revert to the classic flow if there are any issues. '
9+
'An escape hatch is required, as workspace creation is a core workflow and cannot break. '
10+
'This column will be removed when the dynamic parameter creation flow is stable.';
11+
12+
13+
-- Update the template_with_names view by recreating it.
14+
DROP VIEW template_with_names;
15+
CREATE VIEW
16+
template_with_names
17+
AS
18+
SELECT
19+
templates.*,
20+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
21+
coalesce(visible_users.username, '') AS created_by_username,
22+
coalesce(organizations.name, '') AS organization_name,
23+
coalesce(organizations.display_name, '') AS organization_display_name,
24+
coalesce(organizations.icon, '') AS organization_icon
25+
FROM
26+
templates
27+
LEFT JOIN
28+
visible_users
29+
ON
30+
templates.created_by = visible_users.id
31+
LEFT JOIN
32+
organizations
33+
ON templates.organization_id = organizations.id
34+
;
35+
36+
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.UseClassicParameterFlow,
120121
&i.CreatedByAvatarURL,
121122
&i.CreatedByUsername,
122123
&i.OrganizationName,

coderd/database/models.go

Lines changed: 3 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: 13 additions & 6 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ SET
124124
display_name = $6,
125125
allow_user_cancel_workspace_jobs = $7,
126126
group_acl = $8,
127-
max_port_sharing_level = $9
127+
max_port_sharing_level = $9,
128+
use_classic_parameter_flow = $10
128129
WHERE
129130
id = $1
130131
;

0 commit comments

Comments
 (0)