-
Notifications
You must be signed in to change notification settings - Fork 934
feat: add template setting to require active template version #10277
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
Changes from 16 commits
eb5cb38
f31b2fd
3f6dabf
d9bbfea
4b3194d
47da214
92594dc
7abc92b
402b342
508a84d
193388c
3750bda
306d63e
f0c932a
896320c
8315933
8e12b66
6a34bc3
d1a9e43
da82c79
8853b95
6ec940c
cd50482
9ee6898
ef112de
8a4e0bf
693d3a6
3f4ec2e
9e00957
e8ec4bb
a497b71
f336ab1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
|
@@ -915,7 +915,7 @@ func CreateWorkspace(t testing.TB, client *codersdk.Client, organization uuid.UU | |
} | ||
|
||
// TransitionWorkspace is a convenience method for transitioning a workspace from one state to another. | ||
func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID, from, to database.WorkspaceTransition) codersdk.Workspace { | ||
func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID, from, to database.WorkspaceTransition, muts ...func(req *codersdk.CreateWorkspaceBuildRequest)) codersdk.Workspace { | ||
t.Helper() | ||
ctx := context.Background() | ||
workspace, err := client.Workspace(ctx, workspaceID) | ||
|
@@ -925,10 +925,19 @@ func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID | |
template, err := client.Template(ctx, workspace.TemplateID) | ||
require.NoError(t, err, "fetch workspace template") | ||
|
||
build, err := client.CreateWorkspaceBuild(ctx, workspace.ID, codersdk.CreateWorkspaceBuildRequest{ | ||
req := codersdk.CreateWorkspaceBuildRequest{ | ||
// TODO (JonA): I get this is for convenience but we should probably | ||
// change this. Tripped me up why my test was passing when it shouldn't | ||
// have. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand this comment --- change how? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the behavior when calling |
||
TemplateVersionID: template.ActiveVersionID, | ||
Transition: codersdk.WorkspaceTransition(to), | ||
}) | ||
} | ||
|
||
for _, mut := range muts { | ||
mut(&req) | ||
} | ||
|
||
build, err := client.CreateWorkspaceBuild(ctx, workspace.ID, req) | ||
require.NoError(t, err, "unexpected error transitioning workspace to %s", to) | ||
|
||
_ = AwaitWorkspaceBuildJobCompleted(t, client, build.ID) | ||
|
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,25 @@ | ||
BEGIN; | ||
|
||
-- Update the template_with_users view; | ||
DROP VIEW template_with_users; | ||
|
||
ALTER TABLE templates DROP COLUMN require_active_version; | ||
|
||
-- If you need to update this view, put 'DROP VIEW template_with_users;' before this. | ||
CREATE VIEW | ||
template_with_users | ||
AS | ||
SELECT | ||
templates.*, | ||
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, | ||
coalesce(visible_users.username, '') AS created_by_username | ||
FROM | ||
templates | ||
LEFT JOIN | ||
visible_users | ||
ON | ||
templates.created_by = visible_users.id; | ||
|
||
COMMENT ON VIEW template_with_users IS 'Joins in the username + avatar url of the created by user.'; | ||
|
||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
BEGIN; | ||
|
||
DROP VIEW template_with_users; | ||
|
||
ALTER TABLE templates ADD COLUMN require_active_version boolean NOT NULL DEFAULT 'f'; | ||
|
||
CREATE VIEW | ||
template_with_users | ||
AS | ||
SELECT | ||
templates.*, | ||
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, | ||
coalesce(visible_users.username, '') AS created_by_username | ||
FROM | ||
templates | ||
LEFT JOIN | ||
visible_users | ||
ON | ||
templates.created_by = visible_users.id; | ||
|
||
COMMENT ON VIEW template_with_users IS 'Joins in the username + avatar url of the created by user.'; | ||
|
||
COMMIT; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.