Skip to content

Commit 953816a

Browse files
committed
single file compile guard, SiteRoles -> SiteBuiltInRoles
1 parent 7e46d24 commit 953816a

File tree

7 files changed

+15
-41
lines changed

7 files changed

+15
-41
lines changed

coderd/database/no_slim.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
//go:build slim
2+
13
package database
24

35
const (
4-
// This declaration protects against imports in slim builds, see
5-
// no_slim_slim.go.
6-
//nolint:revive,unused
7-
_DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS = "DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS"
6+
// This line fails to compile, preventing this package from being imported
7+
// in slim builds.
8+
_DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS = _DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS
89
)

coderd/database/no_slim_slim.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

coderd/rbac/no_slim.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
//go:build slim
2+
13
package rbac
24

35
const (
4-
// This declaration protects against imports in slim builds, see
5-
// no_slim_slim.go.
6-
//nolint:revive,unused
7-
_DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS = "DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS"
6+
// This line fails to compile, preventing this package from being imported
7+
// in slim builds.
8+
_DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS = _DO_NOT_IMPORT_THIS_PACKAGE_IN_SLIM_BUILDS
89
)

coderd/rbac/no_slim_slim.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

coderd/rbac/roles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,12 +798,12 @@ func OrganizationRoles(organizationID uuid.UUID) []Role {
798798
return roles
799799
}
800800

801-
// SiteRoles lists all roles that can be applied to a user.
801+
// SiteBuiltInRoles lists all roles that can be applied to a user.
802802
// This is the list of available roles, and not specific to a user
803803
//
804804
// This should be a list in a database, but until then we build
805805
// the list from the builtins.
806-
func SiteRoles() []Role {
806+
func SiteBuiltInRoles() []Role {
807807
var roles []Role
808808
for _, roleF := range builtInRoles {
809809
// Must provide some non-nil uuid to filter out org roles.

coderd/rbac/roles_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (a authSubject) Subjects() []authSubject { return []authSubject{a} }
3434
// rules. If this is incorrect, that is a mistake.
3535
func TestBuiltInRoles(t *testing.T) {
3636
t.Parallel()
37-
for _, r := range rbac.SiteRoles() {
37+
for _, r := range rbac.SiteBuiltInRoles() {
3838
r := r
3939
t.Run(r.Identifier.String(), func(t *testing.T) {
4040
t.Parallel()
@@ -997,7 +997,7 @@ func TestIsOrgRole(t *testing.T) {
997997
func TestListRoles(t *testing.T) {
998998
t.Parallel()
999999

1000-
siteRoles := rbac.SiteRoles()
1000+
siteRoles := rbac.SiteBuiltInRoles()
10011001
siteRoleNames := make([]string, 0, len(siteRoles))
10021002
for _, role := range siteRoles {
10031003
siteRoleNames = append(siteRoleNames, role.Identifier.Name)

coderd/roles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (api *API) AssignableSiteRoles(rw http.ResponseWriter, r *http.Request) {
4343
return
4444
}
4545

46-
httpapi.Write(ctx, rw, http.StatusOK, assignableRoles(actorRoles.Roles, rbac.SiteRoles(), dbCustomRoles))
46+
httpapi.Write(ctx, rw, http.StatusOK, assignableRoles(actorRoles.Roles, rbac.SiteBuiltInRoles(), dbCustomRoles))
4747
}
4848

4949
// assignableOrgRoles returns all org wide roles that can be assigned.

0 commit comments

Comments
 (0)