Skip to content

Commit 6016d2f

Browse files
authored
Fix lint (#2427)
1 parent 181dd93 commit 6016d2f

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

client/internal/auth/device_flow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package auth
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"io"
89
"net/http"
@@ -180,7 +181,7 @@ func (d *DeviceAuthorizationFlow) WaitToken(ctx context.Context, info AuthFlowIn
180181
continue
181182
}
182183

183-
return TokenInfo{}, fmt.Errorf(tokenResponse.ErrorDescription)
184+
return TokenInfo{}, errors.New(tokenResponse.ErrorDescription)
184185
}
185186

186187
tokenInfo := TokenInfo{

client/internal/engine.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,9 @@ func (e *Engine) connWorker(conn *peer.Conn, peerKey string) {
960960
for {
961961

962962
// randomize starting time a bit
963-
min := 500
964-
max := 2000
965-
duration := time.Duration(rand.Intn(max-min)+min) * time.Millisecond
963+
minValue := 500
964+
maxValue := 2000
965+
duration := time.Duration(rand.Intn(maxValue-minValue)+minValue) * time.Millisecond
966966
select {
967967
case <-e.ctx.Done():
968968
return

client/internal/routemanager/sysctl/sysctl_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// go:build !android
1+
//go:build !android
2+
23
package sysctl
34

45
import (

client/ssh/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ func (srv *DefaultServer) publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) b
118118

119119
func prepareUserEnv(user *user.User, shell string) []string {
120120
return []string{
121-
fmt.Sprintf("SHELL=" + shell),
122-
fmt.Sprintf("USER=" + user.Username),
123-
fmt.Sprintf("HOME=" + user.HomeDir),
121+
fmt.Sprint("SHELL=" + shell),
122+
fmt.Sprint("USER=" + user.Username),
123+
fmt.Sprint("HOME=" + user.HomeDir),
124124
}
125125
}
126126

management/client/grpc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package client
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78
"sync"
@@ -267,7 +268,7 @@ func (c *GrpcClient) receiveEvents(stream proto.ManagementService_SyncClient, se
267268
// GetServerPublicKey returns server's WireGuard public key (used later for encrypting messages sent to the server)
268269
func (c *GrpcClient) GetServerPublicKey() (*wgtypes.Key, error) {
269270
if !c.ready() {
270-
return nil, fmt.Errorf(errMsgNoMgmtConnection)
271+
return nil, errors.New(errMsgNoMgmtConnection)
271272
}
272273

273274
mgmCtx, cancel := context.WithTimeout(c.ctx, 5*time.Second)
@@ -314,7 +315,7 @@ func (c *GrpcClient) IsHealthy() bool {
314315

315316
func (c *GrpcClient) login(serverKey wgtypes.Key, req *proto.LoginRequest) (*proto.LoginResponse, error) {
316317
if !c.ready() {
317-
return nil, fmt.Errorf(errMsgNoMgmtConnection)
318+
return nil, errors.New(errMsgNoMgmtConnection)
318319
}
319320

320321
loginReq, err := encryption.EncryptMessage(serverKey, c.key, req)
@@ -452,7 +453,7 @@ func (c *GrpcClient) GetPKCEAuthorizationFlow(serverKey wgtypes.Key) (*proto.PKC
452453
// It should be used if there is changes on peer posture check after initial sync.
453454
func (c *GrpcClient) SyncMeta(sysInfo *system.Info) error {
454455
if !c.ready() {
455-
return fmt.Errorf(errMsgNoMgmtConnection)
456+
return errors.New(errMsgNoMgmtConnection)
456457
}
457458

458459
serverPubKey, err := c.GetServerPublicKey()

management/server/grpcserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (s *GRPCServer) validateToken(ctx context.Context, jwtToken string) (string
257257
}
258258

259259
if err := s.accountManager.CheckUserAccessByJWTGroups(ctx, claims); err != nil {
260-
return "", status.Errorf(codes.PermissionDenied, err.Error())
260+
return "", status.Error(codes.PermissionDenied, err.Error())
261261
}
262262

263263
return claims.UserId, nil
@@ -268,15 +268,15 @@ func mapError(ctx context.Context, err error) error {
268268
if e, ok := internalStatus.FromError(err); ok {
269269
switch e.Type() {
270270
case internalStatus.PermissionDenied:
271-
return status.Errorf(codes.PermissionDenied, e.Message)
271+
return status.Error(codes.PermissionDenied, e.Message)
272272
case internalStatus.Unauthorized:
273-
return status.Errorf(codes.PermissionDenied, e.Message)
273+
return status.Error(codes.PermissionDenied, e.Message)
274274
case internalStatus.Unauthenticated:
275-
return status.Errorf(codes.PermissionDenied, e.Message)
275+
return status.Error(codes.PermissionDenied, e.Message)
276276
case internalStatus.PreconditionFailed:
277-
return status.Errorf(codes.FailedPrecondition, e.Message)
277+
return status.Error(codes.FailedPrecondition, e.Message)
278278
case internalStatus.NotFound:
279-
return status.Errorf(codes.NotFound, e.Message)
279+
return status.Error(codes.NotFound, e.Message)
280280
default:
281281
}
282282
}

management/server/http/posture_checks_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func initPostureChecksTestData(postureChecks ...*posture.Checks) *PostureChecksH
4646
testPostureChecks[postureChecks.ID] = postureChecks
4747

4848
if err := postureChecks.Validate(); err != nil {
49-
return status.Errorf(status.InvalidArgument, err.Error())
49+
return status.Errorf(status.InvalidArgument, err.Error()) //nolint
5050
}
5151

5252
return nil

management/server/idp/auth0_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package idp
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"io"
89
"net/http"
@@ -44,14 +45,14 @@ type mockJsonParser struct {
4445

4546
func (m *mockJsonParser) Marshal(v interface{}) ([]byte, error) {
4647
if m.marshalErrorString != "" {
47-
return nil, fmt.Errorf(m.marshalErrorString)
48+
return nil, errors.New(m.marshalErrorString)
4849
}
4950
return m.jsonParser.Marshal(v)
5051
}
5152

5253
func (m *mockJsonParser) Unmarshal(data []byte, v interface{}) error {
5354
if m.unmarshalErrorString != "" {
54-
return fmt.Errorf(m.unmarshalErrorString)
55+
return errors.New(m.unmarshalErrorString)
5556
}
5657
return m.jsonParser.Unmarshal(data, v)
5758
}

management/server/jwtclaims/jwtValidator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (m *JWTValidator) ValidateAndParse(ctx context.Context, token string) (*jwt
150150
// If we get here, the required token is missing
151151
errorMsg := "required authorization token not found"
152152
log.WithContext(ctx).Debugf(" Error: No credentials found (CredentialsOptional=false)")
153-
return nil, fmt.Errorf(errorMsg)
153+
return nil, errors.New(errorMsg)
154154
}
155155

156156
// Now parse the token
@@ -173,7 +173,7 @@ func (m *JWTValidator) ValidateAndParse(ctx context.Context, token string) (*jwt
173173
// Check if the parsed token is valid...
174174
if !parsedToken.Valid {
175175
errorMsg := "token is invalid"
176-
log.WithContext(ctx).Debugf(errorMsg)
176+
log.WithContext(ctx).Debug(errorMsg)
177177
return nil, errors.New(errorMsg)
178178
}
179179

management/server/posture_checks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (am *DefaultAccountManager) SavePostureChecks(ctx context.Context, accountI
6060
}
6161

6262
if err := postureChecks.Validate(); err != nil {
63-
return status.Errorf(status.InvalidArgument, err.Error())
63+
return status.Errorf(status.InvalidArgument, err.Error()) //nolint
6464
}
6565

6666
exists, uniqName := am.savePostureChecks(account, postureChecks)

sharedsock/sock_nolinux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import (
1010

1111
// Listen is not supported on other platforms then Linux
1212
func Listen(port int, filter BPFFilter) (net.PacketConn, error) {
13-
return nil, fmt.Errorf(fmt.Sprintf("Not supported OS %s. SharedSocket is only supported on Linux", runtime.GOOS))
13+
return nil, fmt.Errorf("not supported OS %s. SharedSocket is only supported on Linux", runtime.GOOS)
1414
}

0 commit comments

Comments
 (0)