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

Commitf3f0183

Browse files
committed
refactor: extract PrebuiltWorkspaceResource interface for prebuilt RBAC support
1 parent4b8775f commitf3f0183

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎coderd/database/modelmethods.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ func (gm GroupMember) RBACObject() rbac.Object {
199199
returnrbac.ResourceGroupMember.WithID(gm.UserID).InOrg(gm.OrganizationID).WithOwner(gm.UserID.String())
200200
}
201201

202+
// PrebuiltWorkspaceResource defines the interface for types that can be identified as prebuilt workspaces
203+
// and converted to their corresponding prebuilt workspace RBAC object.
204+
typePrebuiltWorkspaceResourceinterface {
205+
IsPrebuild()bool
206+
AsPrebuild() rbac.Object
207+
}
208+
202209
// WorkspaceTable converts a Workspace to it's reduced version.
203210
// A more generalized solution is to use json marshaling to
204211
// consistently keep these two structs in sync.

‎coderd/workspacebuilds.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,7 @@ func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
396396
}
397397
// Special handling for prebuilt workspace deletion
398398
ifaction==policy.ActionDelete {
399-
ifworkspaceObj,ok:=object.(interface {
400-
IsPrebuild()bool
401-
AsPrebuild() rbac.Object
402-
});ok&&workspaceObj.IsPrebuild() {
399+
ifworkspaceObj,ok:=object.(database.PrebuiltWorkspaceResource);ok&&workspaceObj.IsPrebuild() {
403400
returnapi.Authorize(r,action,workspaceObj.AsPrebuild())
404401
}
405402
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp