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

Commitb022cce

Browse files
authored
feat: add newworkspace:share action type (#20198)
Closes[coder/internal#1012](coder/internal#1012)
1 parent66f1603 commitb022cce

File tree

18 files changed

+101
-10
lines changed

18 files changed

+101
-10
lines changed

‎coderd/apidoc/docs.go‎

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

‎coderd/apidoc/swagger.json‎

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

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ func (q *querier) DeleteWorkspaceACLByID(ctx context.Context, id uuid.UUID) erro
17921792
returnw.WorkspaceTable(),nil
17931793
}
17941794

1795-
returnfetchAndExec(q.log,q.auth,policy.ActionUpdate,fetch,q.db.DeleteWorkspaceACLByID)(ctx,id)
1795+
returnfetchAndExec(q.log,q.auth,policy.ActionShare,fetch,q.db.DeleteWorkspaceACLByID)(ctx,id)
17961796
}
17971797

17981798
func (q*querier)DeleteWorkspaceAgentPortShare(ctx context.Context,arg database.DeleteWorkspaceAgentPortShareParams)error {
@@ -3388,7 +3388,7 @@ func (q *querier) GetWorkspaceACLByID(ctx context.Context, id uuid.UUID) (databa
33883388
iferr!=nil {
33893389
return database.GetWorkspaceACLByIDRow{},err
33903390
}
3391-
iferr:=q.authorizeContext(ctx,policy.ActionCreate,workspace);err!=nil {
3391+
iferr:=q.authorizeContext(ctx,policy.ActionShare,workspace);err!=nil {
33923392
return database.GetWorkspaceACLByIDRow{},err
33933393
}
33943394
returnq.db.GetWorkspaceACLByID(ctx,id)
@@ -5312,7 +5312,7 @@ func (q *querier) UpdateWorkspaceACLByID(ctx context.Context, arg database.Updat
53125312
returnw.WorkspaceTable(),nil
53135313
}
53145314

5315-
returnfetchAndExec(q.log,q.auth,policy.ActionCreate,fetch,q.db.UpdateWorkspaceACLByID)(ctx,arg)
5315+
returnfetchAndExec(q.log,q.auth,policy.ActionShare,fetch,q.db.UpdateWorkspaceACLByID)(ctx,arg)
53165316
}
53175317

53185318
func (q*querier)UpdateWorkspaceAgentConnectionByID(ctx context.Context,arg database.UpdateWorkspaceAgentConnectionByIDParams)error {

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,20 +1732,20 @@ func (s *MethodTestSuite) TestWorkspace() {
17321732
ws:=testutil.Fake(s.T(),faker, database.Workspace{})
17331733
dbM.EXPECT().GetWorkspaceByID(gomock.Any(),ws.ID).Return(ws,nil).AnyTimes()
17341734
dbM.EXPECT().GetWorkspaceACLByID(gomock.Any(),ws.ID).Return(database.GetWorkspaceACLByIDRow{},nil).AnyTimes()
1735-
check.Args(ws.ID).Asserts(ws,policy.ActionCreate)
1735+
check.Args(ws.ID).Asserts(ws,policy.ActionShare)
17361736
}))
17371737
s.Run("UpdateWorkspaceACLByID",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
17381738
w:=testutil.Fake(s.T(),faker, database.Workspace{})
17391739
arg:= database.UpdateWorkspaceACLByIDParams{ID:w.ID}
17401740
dbm.EXPECT().GetWorkspaceByID(gomock.Any(),w.ID).Return(w,nil).AnyTimes()
17411741
dbm.EXPECT().UpdateWorkspaceACLByID(gomock.Any(),arg).Return(nil).AnyTimes()
1742-
check.Args(arg).Asserts(w,policy.ActionCreate)
1742+
check.Args(arg).Asserts(w,policy.ActionShare)
17431743
}))
17441744
s.Run("DeleteWorkspaceACLByID",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
17451745
w:=testutil.Fake(s.T(),faker, database.Workspace{})
17461746
dbm.EXPECT().GetWorkspaceByID(gomock.Any(),w.ID).Return(w,nil).AnyTimes()
17471747
dbm.EXPECT().DeleteWorkspaceACLByID(gomock.Any(),w.ID).Return(nil).AnyTimes()
1748-
check.Args(w.ID).Asserts(w,policy.ActionUpdate)
1748+
check.Args(w.ID).Asserts(w,policy.ActionShare)
17491749
}))
17501750
s.Run("GetLatestWorkspaceBuildByWorkspaceID",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
17511751
w:=testutil.Fake(s.T(),faker, database.Workspace{})

‎coderd/database/dump.sql‎

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- No-op: keep enum values to avoid dependency churn.
2+
-- If strict removal is required, create a new enum type without these values,
3+
-- cast columns, drop the old type, and rename.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTERTYPE api_key_scope ADD VALUE IF NOT EXISTS'workspace:share';
2+
ALTERTYPE api_key_scope ADD VALUE IF NOT EXISTS'workspace_dormant:share';

‎coderd/database/models.go‎

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

‎coderd/rbac/object_gen.go‎

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

‎coderd/rbac/policy/policy.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727

2828
ActionCreateAgentAction="create_agent"
2929
ActionDeleteAgentAction="delete_agent"
30+
31+
ActionShareAction="share"
3032
)
3133

3234
typePermissionDefinitionstruct {
@@ -61,6 +63,9 @@ var workspaceActions = map[Action]ActionDefinition{
6163

6264
ActionCreateAgent:"create a new workspace agent",
6365
ActionDeleteAgent:"delete an existing workspace agent",
66+
67+
// Sharing a workspace
68+
ActionShare:"share a workspace with other users or groups",
6469
}
6570

6671
vartaskActions=map[Action]ActionDefinition{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp