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

Commitf36ae37

Browse files
committed
Renamings
1 parent1498dcd commitf36ae37

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

‎coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func New(options *Options) (http.Handler, func()) {
159159
})
160160
r.Route("/members",func(r chi.Router) {
161161
r.Route("/roles",func(r chi.Router) {
162-
r.Use(httpmw.RBACObject(rbac.ResourceUserRole))
162+
r.Use(httpmw.WithRBACObject(rbac.ResourceUserRole))
163163
r.Get("/",authorize(api.assignableOrgRoles,rbac.ActionRead))
164164
})
165165
r.Route("/{user}",func(r chi.Router) {
@@ -232,7 +232,7 @@ func New(options *Options) (http.Handler, func()) {
232232
r.Get("/",api.users)
233233
// These routes query information about site wide roles.
234234
r.Route("/roles",func(r chi.Router) {
235-
r.Use(httpmw.RBACObject(rbac.ResourceUserRole))
235+
r.Use(httpmw.WithRBACObject(rbac.ResourceUserRole))
236236
r.Get("/",authorize(api.assignableSiteRoles,rbac.ActionRead))
237237
})
238238
r.Route("/{user}",func(r chi.Router) {

‎coderd/httpmw/authorize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func GetAuthObject(r *http.Request) AuthObject {
8888
returnobj
8989
}
9090

91-
//RBACObject sets the object for 'Authorize()' for all routes handled
91+
//WithRBACObject sets the object for 'Authorize()' for all routes handled
9292
// by this middleware. The important field to set is 'Type'
93-
funcRBACObject(object rbac.Object)func(http.Handler) http.Handler {
93+
funcWithRBACObject(object rbac.Object)func(http.Handler) http.Handler {
9494
returnfunc(next http.Handler) http.Handler {
9595
returnhttp.HandlerFunc(func(rw http.ResponseWriter,r*http.Request) {
9696
ao:=GetAuthObject(r)
@@ -105,7 +105,7 @@ func RBACObject(object rbac.Object) func(http.Handler) http.Handler {
105105
// User roles are the 'subject' field of Authorize()
106106
typeuserRolesKeystruct{}
107107

108-
//APIKey returns the API key from theExtractAPIKey handler.
108+
//UserRoles returns the API key from theExtractUserRoles handler.
109109
funcUserRoles(r*http.Request) database.GetAllUserRolesRow {
110110
apiKey,ok:=r.Context().Value(userRolesKey{}).(database.GetAllUserRolesRow)
111111
if!ok {

‎coderd/rbac/builtin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ func IsOrgRole(roleName string) (string, bool) {
145145
return"",false
146146
}
147147

148-
//ListOrganizationRoles lists all roles that can be applied to an organization user
148+
//OrganizationRoles lists all roles that can be applied to an organization user
149149
// in the given organization.
150-
//Note:This should be a list in a database, but until then we build
150+
// This should be a list in a database, but until then we build
151151
// the list from the builtins.
152-
funcListOrganizationRoles(organizationID uuid.UUID) []string {
152+
funcOrganizationRoles(organizationID uuid.UUID) []string {
153153
varroles []string
154154
forrole:=rangebuiltInRoles {
155155
_,scope,err:=roleSplit(role)
@@ -164,10 +164,10 @@ func ListOrganizationRoles(organizationID uuid.UUID) []string {
164164
returnroles
165165
}
166166

167-
//ListSiteRoles lists all roles that can be applied to a user.
168-
//Note:This should be a list in a database, but until then we build
167+
//SiteRoles lists all roles that can be applied to a user.
168+
// This should be a list in a database, but until then we build
169169
// the list from the builtins.
170-
funcListSiteRoles() []string {
170+
funcSiteRoles() []string {
171171
varroles []string
172172
forrole:=rangebuiltInRoles {
173173
_,scope,err:=roleSplit(role)

‎coderd/roles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
func (api*api)assignableSiteRoles(rw http.ResponseWriter,r*http.Request) {
1212
// TODO: @emyrk in the future, allow granular subsets of roles to be returned based on the
1313
// role of the user.
14-
roles:=rbac.ListSiteRoles()
14+
roles:=rbac.SiteRoles()
1515
httpapi.Write(rw,http.StatusOK,roles)
1616
}
1717

1818
// assignableSiteRoles returns all site wide roles that can be assigned.
1919
func (api*api)assignableOrgRoles(rw http.ResponseWriter,r*http.Request) {
2020
// TODO: @emyrk in the future, allow granular subsets of roles to be returned based on the
2121
// role of the user.
22-
roles:=rbac.ListSiteRoles()
22+
roles:=rbac.SiteRoles()
2323
httpapi.Write(rw,http.StatusOK,roles)
2424
}

‎coderd/roles_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestListRoles(t *testing.T) {
8484
returnorgAdmin.ListOrganizationRoles(ctx,admin.OrganizationID)
8585
},
8686
Authorized:true,
87-
ExpectedRoles:rbac.ListOrganizationRoles(admin.OrganizationID),
87+
ExpectedRoles:rbac.OrganizationRoles(admin.OrganizationID),
8888
},
8989
{
9090
Name:"OrgAdminListOtherOrg",
@@ -100,15 +100,15 @@ func TestListRoles(t *testing.T) {
100100
returnclient.ListSiteRoles(ctx)
101101
},
102102
Authorized:true,
103-
ExpectedRoles:rbac.ListSiteRoles(),
103+
ExpectedRoles:rbac.SiteRoles(),
104104
},
105105
{
106106
Name:"AdminListOrg",
107107
APICall:func() ([]string,error) {
108108
returnclient.ListOrganizationRoles(ctx,admin.OrganizationID)
109109
},
110110
Authorized:true,
111-
ExpectedRoles:rbac.ListOrganizationRoles(admin.OrganizationID),
111+
ExpectedRoles:rbac.OrganizationRoles(admin.OrganizationID),
112112
},
113113
}
114114

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp