8000 Do not export convert functions · coder/coder@dda5809 · GitHub
[go: up one dir, main page]

Skip to content

Commit dda5809

Browse files
committed
Do not export convert functions
1 parent 440308f commit dda5809

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

coderd/roles.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (*api) assignableSiteRoles(rw http.ResponseWriter, _ *http.Request) {
1515
// TODO: @emyrk in the future, allow granular subsets of roles to be returned based on the
1616
// role of the user.
1717
roles := rbac.SiteRoles()
18-
httpapi.Write(rw, http.StatusOK, ConvertRoles(roles))
18+
httpapi.Write(rw, http.StatusOK, convertRoles(roles))
1919
}
2020

2121
// assignableSiteRoles returns all site wide roles that can be assigned.
@@ -24,20 +24,20 @@ func (*api) assignableOrgRoles(rw http.ResponseWriter, r *http.Request) {
2424
// role of the user.
2525
organization := httpmw.OrganizationParam(r)
2626
roles := rbac.OrganizationRoles(organization.ID)
27-
httpapi.Write(rw, http.StatusOK, ConvertRoles(roles))
27+
httpapi.Write(rw, http.StatusOK, convertRoles(roles))
2828
}
2929

30-
func ConvertRole(role rbac.Role) codersdk.Role {
30+
func convertRole(role rbac.Role) codersdk.Role {
3131
return codersdk.Role{
3232
DisplayName: role.DisplayName,
3333
Name: role.Name,
3434
}
3535
}
3636

37-
func ConvertRoles(roles []rbac.Role) []codersdk.Role {
37+
func convertRoles(roles []rbac.Role) []codersdk.Role {
3838
converted := make([]codersdk.Role, 0, len(roles))
3939
for _, role := range roles {
40-
converted = append(converted, ConvertRole(role))
40+
converted = append(converted, convertRole(role))
4141
}
4242
return converted
4343
}

coderd/roles_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/stretchr/testify/require"
99

10-
"github.com/coder/coder/coderd"
1110
"github.com/coder/coder/coderd/coderdtest"
1211
"github.com/coder/coder/coderd/rbac"
1312
"github.com/coder/coder/codersdk"
@@ -85,7 +84,7 @@ func TestListRoles(t *testing.T) {
8584
APICall: func() ([]codersdk.Role, error) {
8685
return orgAdmin.ListOrganizationRoles(ctx, admin.OrganizationID)
8786
},
88-
ExpectedRoles: coderd.ConvertRoles(rbac.OrganizationRoles(admin.OrganizationID)),
87+
ExpectedRoles: convertRoles(rbac.OrganizationRoles(admin.OrganizationID)),
8988
},
9089
{
9190
Name: "OrgAdminListOtherOrg",
@@ -100,14 +99,14 @@ func TestListRoles(t *testing.T) {
10099
APICall: func() ([]codersdk.Role, error) {
101100
return client.ListSiteRoles(ctx)
102101
},
103-
ExpectedRoles: coderd.ConvertRoles(rbac.SiteRoles()),
102+
ExpectedRoles: convertRoles(rbac.SiteRoles()),
104103
},
105104
{
106105
Name: "AdminListOrg",
107106
APICall: func() ([]codersdk.Role, error) {
108107
return client.ListOrganizationRoles(ctx, admin.OrganizationID)
109108
},
110-
ExpectedRoles: coderd.ConvertRoles(rbac.OrganizationRoles(admin.OrganizationID)),
109+
ExpectedRoles: convertRoles(rbac.OrganizationRoles(admin.OrganizationID)),
111110
},
112111
}
113112

@@ -128,3 +127,18 @@ func TestListRoles(t *testing.T) {
128127
})
129128
}
130129
}
130+
131+
func convertRole(role rbac.Role) codersdk.Role {
132+
return codersdk.Role{
133+
DisplayName: role.DisplayName,
134+
Name: role.Name,
135+
}
136+
}
137+
138+
func convertRoles(roles []rbac.Role) []codersdk.Role {
139+
converted := make([]codersdk.Role, 0, len(roles))
140+
for _, role := range roles {
141+
converted = append(converted, convertRole(role))
142+
}
143+
return converted
144+
}

0 commit comments

Comments
 (0)
0