Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22db0d2

Browse files
authored
migrate existing templates (#4353)
1 parent9bfa415 commit22db0d2

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

‎coderd/database/migrations/000055_template_acl.up.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,30 @@ CREATE TABLE group_members (
1919
UNIQUE(user_id, group_id)
2020
);
2121

22+
-- Insert a group for every organization (which should just be 1).
23+
INSERT INTO groups (
24+
id,
25+
name,
26+
organization_id
27+
)SELECT
28+
id,'Everyone'as name, id
29+
FROM
30+
organizations;
31+
32+
-- Insert allUsers groups into every existing template to avoid breaking
33+
-- existing deployments.
34+
UPDATE
35+
templates
36+
SET
37+
group_acl= (
38+
SELECT
39+
json_build_object(
40+
organizations.id, array_to_json('{"read"}'::text[])
41+
)
42+
FROM
43+
organizations
44+
WHERE
45+
templates.organization_id=organizations.id
46+
);
47+
2248
COMMIT;

‎coderd/database/modelmethods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/coder/coder/coderd/rbac"
88
)
99

10-
constAllUsersGroup="allUsers"
10+
constAllUsersGroup="Everyone"
1111

1212
// TemplateACL is a map of user_ids to permissions.
1313
typeTemplateACLmap[string][]rbac.Action

‎coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/groups.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ INSERT INTO groups (
8989
organization_id
9090
)
9191
VALUES
92-
(sqlc.arg(organization_id),'allUsers',sqlc.arg(organization_id)) RETURNING*;
92+
(sqlc.arg(organization_id),'Everyone',sqlc.arg(organization_id)) RETURNING*;
9393

9494
-- name: UpdateGroupByID :one
9595
UPDATE

‎coderd/rbac/authz_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func TestAuthorizeDomain(t *testing.T) {
195195
t.Parallel()
196196
defOrg:=uuid.New()
197197
unuseID:=uuid.New()
198-
allUsersGroup:="allUsers"
198+
allUsersGroup:="Everyone"
199199

200200
user:=subject{
201201
UserID:"me",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp