Skip to content

Commit bff6ce4

Browse files
committed
ForbiddenStatusError: make linter happy on error construction
Signed-off-by: Monis Khan <[email protected]>
1 parent 857127f commit bff6ce4

File tree

1 file changed

+4
-4
lines changed
  • staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters

1 file changed

+4
-4
lines changed

staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ func Forbidden(ctx context.Context, attributes authorizer.Attributes, w http.Res
4242
func ForbiddenStatusError(attributes authorizer.Attributes, reason string) *apierrors.StatusError {
4343
msg := sanitizer.Replace(forbiddenMessage(attributes))
4444

45-
var errMsg string
45+
var errMsg error
4646
if len(reason) == 0 {
47-
errMsg = fmt.Sprintf("%s", msg)
47+
errMsg = fmt.Errorf("%s", msg)
4848
} else {
49-
errMsg = fmt.Sprintf("%s: %s", msg, reason)
49+
errMsg = fmt.Errorf("%s: %s", msg, reason)
5050
}
5151

5252
gr := schema.GroupResource{Group: attributes.GetAPIGroup(), Resource: attributes.GetResource()}
5353

54-
return apierrors.NewForbidden(gr, attributes.GetName(), fmt.Errorf(errMsg))
54+
return apierrors.NewForbidden(gr, attributes.GetName(), errMsg)
5555
}
5656

5757
func forbiddenMessage(attributes authorizer.Attributes) string {

0 commit comments

Comments
 (0)