-
Notifications
You must be signed in to change notification settings - Fork 903
feat: implement deprecated flag for templates to prevent new workspaces #10745
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 15 commits
c2b05f0
628b97a
0935732
33f54f8
f5dc43f
4cfa940
873300f
576837c
a9922dc
7b647da
143062a
00cc2b8
cdf2945
8db1dd6
0b1c720
af8226d
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 |
---|---|---|
|
@@ -614,6 +614,21 @@ func CreateAnotherUserMutators(t testing.TB, client *codersdk.Client, organizati | |
return createAnotherUserRetry(t, client, organizationID, 5, roles, mutators...) | ||
} | ||
|
||
// AuthzUserSubject does not include the user's groups. | ||
func AuthzUserSubject(user codersdk.User) rbac.Subject { | ||
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. That's handy! 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. Yup, got tired of using |
||
roles := make(rbac.RoleNames, 0, len(user.Roles)) | ||
for _, r := range user.Roles { | ||
roles = append(roles, r.Name) | ||
} | ||
|
||
return rbac.Subject{ | ||
ID: user.ID.String(), | ||
Roles: roles, | ||
Groups: []string{}, | ||
Scope: rbac.ScopeAll, | ||
} | ||
} | ||
|
||
func createAnotherUserRetry(t testing.TB, client *codersdk.Client, organizationID uuid.UUID, retries int, roles []string, mutators ...func(r *codersdk.CreateUserRequest)) (*codersdk.Client, codersdk.User) { | ||
req := codersdk.CreateUserRequest{ | ||
Email: namesgenerator.GetRandomName(10) + "@coder.com", | ||
|
@@ -689,7 +704,7 @@ func createAnotherUserRetry(t testing.TB, client *codersdk.Client, organizationI | |
siteRoles = append(siteRoles, r.Name) | ||
} | ||
|
||
_, err := client.UpdateUserRoles(context.Background(), user.ID.String(), codersdk.UpdateRoles{Roles: siteRoles}) | ||
user, err = client.UpdateUserRoles(context.Background(), user.ID.String(), codersdk.UpdateRoles{Roles: siteRoles}) | ||
require.NoError(t, err, "update site roles") | ||
|
||
// Update org roles | ||
|
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,24 @@ | ||
BEGIN; | ||
|
||
DROP VIEW template_with_users; | ||
|
||
ALTER TABLE templates | ||
DROP COLUMN deprecated; | ||
|
||
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,28 @@ | ||
BEGIN; | ||
|
||
-- The view will be rebuilt with the new column | ||
DROP VIEW template_with_users; | ||
|
||
ALTER TABLE templates | ||
ADD COLUMN deprecated TEXT NOT NULL DEFAULT ''; | ||
|
||
COMMENT ON COLUMN templates.deprecated IS 'If set to a non empty string, the template will no longer be able to be used. The message will be displayed to the user.'; | ||
|
||
-- Restore the old version of the template_with_users view. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.