Skip to content

Commit e6d5c2f

Browse files
committed
Linting
1 parent 8780e4e commit e6d5c2f

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

coderd/authzquery/authz.go

-11
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func authorizedInsert[ArgumentType any,
6262
action rbac.Action,
6363
object rbac.Objecter,
6464
insertFunc Insert) Insert {
65-
6665
return func(ctx context.Context, arg ArgumentType) error {
6766
_, err := authorizedInsertWithReturn(logger, authorizer, action, object, func(ctx context.Context, arg ArgumentType) (rbac.Objecter, error) {
6867
return rbac.Object{}, insertFunc(ctx, arg)
@@ -79,7 +78,6 @@ func authorizedInsertWithReturn[ObjectType any, ArgumentType any,
7978
action rbac.Action,
8079
object rbac.Objecter,
8180
insertFunc Insert) Insert {
82-
8381
return func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) {
8482
// Fetch the rbac subject
8583
act, ok := ActorFromContext(ctx)
@@ -106,7 +104,6 @@ func authorizedDelete[ObjectType rbac.Objecter, ArgumentType any,
106104
authorizer rbac.Authorizer,
107105
fetchFunc Fetch,
108106
deleteFunc Delete) Delete {
109-
110107
return authorizedFetchAndExec(logger, authorizer,
111108
rbac.ActionDelete, fetchFunc, deleteFunc)
112109
}
@@ -120,7 +117,6 @@ func authorizedUpdateWithReturn[ObjectType rbac.Objecter,
120117
authorizer rbac.Authorizer,
121118
fetchFunc Fetch,
122119
updateQuery UpdateQuery) UpdateQuery {
123-
124120
return authorizedFetchAndQuery(logger, authorizer, rbac.ActionUpdate, fetchFunc, updateQuery)
125121
}
126122

@@ -133,7 +129,6 @@ func authorizedUpdate[ObjectType rbac.Objecter,
133129
authorizer rbac.Authorizer,
134130
fetchFunc Fetch,
135131
updateExec Exec) Exec {
136-
137132
return authorizedFetchAndExec(logger, authorizer, rbac.ActionUpdate, fetchFunc, updateExec)
138133
}
139134

@@ -150,7 +145,6 @@ func authorizedFetchAndExec[ObjectType rbac.Objecter,
150145
action rbac.Action,
151146
fetchFunc Fetch,
152147
execFunc Exec) Exec {
153-
154148
f := authorizedFetchAndQuery(logger, authorizer, action, fetchFunc, func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) {
155149
return empty, execFunc(ctx, arg)
156150
})
@@ -169,7 +163,6 @@ func authorizedFetchAndQuery[ObjectType rbac.Objecter, ArgumentType any,
169163
action rbac.Action,
170164
fetchFunc Fetch,
171165
queryFunc Query) Query {
172-
173166
return func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) {
174167
// Fetch the rbac subject
175168
act, ok := ActorFromContext(ctx)
@@ -199,7 +192,6 @@ func authorizedFetch[ObjectType rbac.Objecter, ArgumentType any,
199192
logger slog.Logger,
200193
authorizer rbac.Authorizer,
201194
fetchFunc Fetch) Fetch {
202-
203195
return authorizedQuery(logger, authorizer, rbac.ActionRead, fetchFunc)
204196
}
205197

@@ -220,7 +212,6 @@ func authorizedQuery[ArgumentType any, ObjectType rbac.Objecter,
220212
authorizer rbac.Authorizer,
221213
action rbac.Action,
222214
f DatabaseFunc) DatabaseFunc {
223-
224215
return func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) {
225216
// Fetch the rbac subject
226217
act, ok := ActorFromContext(ctx)
@@ -251,7 +242,6 @@ func authorizedFetchSet[ArgumentType any, ObjectType rbac.Objecter,
251242
// Arguments
252243
authorizer rbac.Authorizer,
253244
f DatabaseFunc) DatabaseFunc {
254-
255245
return func(ctx context.Context, arg ArgumentType) (empty []ObjectType, err error) {
256246
// Fetch the rbac subject
257247
act, ok := ActorFromContext(ctx)
@@ -283,7 +273,6 @@ func authorizedQueryWithRelated[ObjectType any, ArgumentType any, Related rbac.O
283273
action rbac.Action,
284274
relatedFunc func(ObjectType, ArgumentType) (Related, error),
285275
fetch func(ctx context.Context, arg ArgumentType) (ObjectType, error)) func(ctx context.Context, arg ArgumentType) (ObjectType, error) {
286-
287276
return func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) {
288277
// Fetch the rbac subject
289278
act, ok := ActorFromContext(ctx)

coderd/rbac/error_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
package rbac
1+
package rbac_test
22

33
import (
44
"testing"
55

6+
"github.com/coder/coder/coderd/rbac"
7+
68
"github.com/stretchr/testify/require"
79
"golang.org/x/xerrors"
810
)
@@ -12,19 +14,19 @@ func TestIsUnauthorizedError(t *testing.T) {
1214
t.Run("NotWrapped", func(t *testing.T) {
1315
t.Parallel()
1416
errFunc := func() error {
15-
return UnauthorizedError{}
17+
return rbac.UnauthorizedError{}
1618
}
1719

1820
err := errFunc()
19-
require.True(t, IsUnauthorizedError(err))
21+
require.True(t, rbac.IsUnauthorizedError(err))
2022
})
2123

2224
t.Run("Wrapped", func(t *testing.T) {
2325
t.Parallel()
2426
errFunc := func() error {
25-
return xerrors.Errorf("test error: %w", UnauthorizedError{})
27+
return xerrors.Errorf("test error: %w", rbac.UnauthorizedError{})
2628
}
2729
err := errFunc()
28-
require.True(t, IsUnauthorizedError(err))
30+
require.True(t, rbac.IsUnauthorizedError(err))
2931
})
3032
}

0 commit comments

Comments
 (0)