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

Commit854f3c0

Browse files
authored
feat: add workspaces/acl [delete] endpoint (#19772)
Closes[coder/internal#971](coder/internal#971)
1 parent8e79dbb commit854f3c0

File tree

15 files changed

+371
-0
lines changed

15 files changed

+371
-0
lines changed

‎coderd/apidoc/docs.go‎

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

‎coderd/coderd.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ func New(options *Options) *API {
14571457

14581458
r.Get("/",api.workspaceACL)
14591459
r.Patch("/",api.patchWorkspaceACL)
1460+
r.Delete("/",api.deleteWorkspaceACL)
14601461
})
14611462
})
14621463
})

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,18 @@ func (q *querier) DeleteWebpushSubscriptions(ctx context.Context, ids []uuid.UUI
17331733
returnq.db.DeleteWebpushSubscriptions(ctx,ids)
17341734
}
17351735

1736+
func (q*querier)DeleteWorkspaceACLByID(ctx context.Context,id uuid.UUID)error {
1737+
fetch:=func(ctx context.Context,id uuid.UUID) (database.WorkspaceTable,error) {
1738+
w,err:=q.db.GetWorkspaceByID(ctx,id)
1739+
iferr!=nil {
1740+
return database.WorkspaceTable{},err
1741+
}
1742+
returnw.WorkspaceTable(),nil
1743+
}
1744+
1745+
returnfetchAndExec(q.log,q.auth,policy.ActionUpdate,fetch,q.db.DeleteWorkspaceACLByID)(ctx,id)
1746+
}
1747+
17361748
func (q*querier)DeleteWorkspaceAgentPortShare(ctx context.Context,arg database.DeleteWorkspaceAgentPortShareParams)error {
17371749
w,err:=q.db.GetWorkspaceByID(ctx,arg.WorkspaceID)
17381750
iferr!=nil {

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,12 @@ func (s *MethodTestSuite) TestWorkspace() {
16991699
dbm.EXPECT().UpdateWorkspaceACLByID(gomock.Any(),arg).Return(nil).AnyTimes()
17001700
check.Args(arg).Asserts(w,policy.ActionCreate)
17011701
}))
1702+
s.Run("DeleteWorkspaceACLByID",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
1703+
w:=testutil.Fake(s.T(),faker, database.Workspace{})
1704+
dbm.EXPECT().GetWorkspaceByID(gomock.Any(),w.ID).Return(w,nil).AnyTimes()
1705+
dbm.EXPECT().DeleteWorkspaceACLByID(gomock.Any(),w.ID).Return(nil).AnyTimes()
1706+
check.Args(w.ID).Asserts(w,policy.ActionUpdate)
1707+
}))
17021708
s.Run("GetLatestWorkspaceBuildByWorkspaceID",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
17031709
w:=testutil.Fake(s.T(),faker, database.Workspace{})
17041710
b:=testutil.Fake(s.T(),faker, database.WorkspaceBuild{WorkspaceID:w.ID})

‎coderd/database/dbmetrics/querymetrics.go‎

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

‎coderd/database/dbmock/dbmock.go‎

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

‎coderd/database/querier.go‎

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

‎coderd/database/queries.sql.go‎

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

‎coderd/database/queries/workspaces.sql‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,15 @@ SET
924924
WHERE
925925
id= @id;
926926

927+
-- name: DeleteWorkspaceACLByID :exec
928+
UPDATE
929+
workspaces
930+
SET
931+
group_acl='{}'::json,
932+
user_acl='{}'::json
933+
WHERE
934+
id= @id;
935+
927936
-- name: GetRegularWorkspaceCreateMetrics :many
928937
-- Count regular workspaces: only those whose first successful 'start' build
929938
-- was not initiated by the prebuild system user.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp