Skip to content

Commit b4747c1

Browse files
committed
fix lint
1 parent 5c99132 commit b4747c1

30 files changed

+71
-67
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ jobs:
6161
with:
6262
go-version-file: go.mod
6363
check-latest: true
64-
- uses: golangci/golangci-lint-action@v3
64+
- uses: golangci/golangci-lint-action@v6.1.1
6565
with:
6666
version: v1.63.4

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ linters:
2626
- goconst
2727
- gocritic
2828
- misspell
29+
30+
issues:
31+
# Excluding configuration per-path, per-linter, per-text and per-source
32+
exclude-files:
33+
# Exclude some linters from running on tests files.
34+
- .*_test\.go

cmd/agentk/agentkapp/app.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/ash2k/stager"
1515
"github.com/go-logr/zapr"
1616
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
17+
"go.opentelemetry.io/otel/trace/noop"
1718

1819
"github.com/pluralsh/kuberentes-agent/cmd"
1920
"github.com/pluralsh/kuberentes-agent/pkg/agentcfg"
@@ -36,6 +37,7 @@ import (
3637
"github.com/pluralsh/kuberentes-agent/pkg/tool/tlstool"
3738
"github.com/pluralsh/kuberentes-agent/pkg/tool/wstunnel"
3839

40+
"github.com/coder/websocket"
3941
"github.com/prometheus/client_golang/prometheus"
4042
"github.com/prometheus/client_golang/prometheus/collectors"
4143
"github.com/spf13/cobra"
@@ -61,7 +63,6 @@ import (
6163
"k8s.io/client-go/tools/record"
6264
"k8s.io/klog/v2"
6365
"k8s.io/kubectl/pkg/cmd/util"
64-
"nhooyr.io/websocket"
6566
"sigs.k8s.io/controller-runtime/pkg/log"
6667
)
6768

@@ -129,7 +130,7 @@ func (a *App) Run(ctx context.Context) (retErr error) {
129130
unaryClientProm := clientProm.UnaryClientInterceptor()
130131

131132
// TODO Tracing
132-
tp := trace.NewNoopTracerProvider()
133+
tp := noop.NewTracerProvider()
133134
p := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
134135

135136
// TODO metrics via OTEL
@@ -416,7 +417,7 @@ func (a *App) constructKasConnection(ctx context.Context, tp trace.TracerProvide
416417
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
417418
}
418419
opts = append(opts, grpc.WithPerRPCCredentials(grpctool2.NewTokenCredentials(a.AgentToken, !secure)))
419-
conn, err := grpc.DialContext(ctx, addressToDial, opts...)
420+
conn, err := grpc.NewClient(addressToDial, opts...)
420421
if err != nil {
421422
return nil, fmt.Errorf("gRPC.dial: %w", err)
422423
}

cmd/agentk/agentkapp/app_internal_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func newInternalServer(log *zap.Logger, tp trace.TracerProvider, mp otelmetric.M
3232
listener := grpctool2.NewDialListener()
3333

3434
// Construct connection to internal gRPC server
35-
conn, err := grpc.DialContext(context.Background(), "passthrough:pipe", // nolint: contextcheck
35+
conn, err := grpc.NewClient("passthrough:pipe", // nolint: contextcheck
3636
grpc.WithSharedWriteBuffer(true),
3737
grpc.WithContextDialer(listener.DialContext),
3838
grpc.WithTransportCredentials(insecure.NewCredentials()),

cmd/kas/kasapp/app_agent_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/pluralsh/kuberentes-agent/pkg/tool/tlstool"
2222
"github.com/pluralsh/kuberentes-agent/pkg/tool/wstunnel"
2323

24+
"github.com/coder/websocket"
2425
"github.com/prometheus/client_golang/prometheus"
2526
"github.com/redis/rueidis"
2627
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
@@ -32,7 +33,6 @@ import (
3233
"google.golang.org/grpc/credentials"
3334
"google.golang.org/grpc/keepalive"
3435
"google.golang.org/grpc/stats"
35-
"nhooyr.io/websocket"
3636
)
3737

3838
const (

cmd/kas/kasapp/app_internal_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package kasapp
22

33
import (
4-
"context"
54
"net"
65

76
"github.com/ash2k/stager"
@@ -32,7 +31,7 @@ func newInternalServer(tp trace.TracerProvider, mp otelmetric.MeterProvider, p p
3231
listener := grpctool2.NewDialListener()
3332

3433
// Construct connection to internal gRPC server
35-
conn, err := grpc.DialContext(context.Background(), "passthrough:pipe", // nolint: contextcheck
34+
conn, err := grpc.NewClient("passthrough:pipe", // nolint: contextcheck
3635
grpc.WithStatsHandler(otelgrpc.NewServerHandler(
3736
otelgrpc.WithTracerProvider(tp),
3837
otelgrpc.WithMeterProvider(mp),

cmd/kas/kasapp/app_private_api_server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func newKasPool(log *zap.Logger, errRep errz.ErrReporter, tp trace.TracerProvide
240240
}
241241

242242
// Construct in-memory connection to private API gRPC server
243-
inMemConn, err := grpc.DialContext(context.Background(), "passthrough:pipe", // nolint: contextcheck
243+
inMemConn, err := grpc.NewClient("passthrough:pipe", // nolint: contextcheck
244244
append([]grpc.DialOption{
245245
grpc.WithContextDialer(dialer),
246246
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -350,7 +350,7 @@ func detectUrlByCIDR(interfaceAddrs func() ([]net.Addr, error),
350350
return "", fmt.Errorf("listener address: %w", err)
351351
}
352352
portStr = listenPort
353-
//case "unix": We don't handle unix scheme here because we got OWN_PRIVATE_API_CIDR and hence presumably
353+
// case "unix": We don't handle unix scheme here because we got OWN_PRIVATE_API_CIDR and hence presumably
354354
// user wants to use network, not unix socket.
355355
default:
356356
return "", fmt.Errorf("cannot determine port for own URL. Specify %s", envVarOwnPrivateApiPort)

cmd/kas/kasapp/configured_app.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/ash2k/stager"
1616
"github.com/getsentry/sentry-go"
1717
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
18+
"go.opentelemetry.io/otel/trace/noop"
1819

1920
usage_metrics_server "github.com/pluralsh/kuberentes-agent/pkg/module/usage_metrics/server"
2021

@@ -450,7 +451,10 @@ func (a *ConfiguredApp) constructRedisClient(tp trace.TracerProvider, mp otelmet
450451
}
451452
if a.isTracingEnabled() {
452453
// Instrument Redis client with tracing only if it's configured.
453-
redisClient = rueidisotel.WithClient(redisClient, rueidisotel.WithTracerProvider(tp), rueidisotel.WithMeterProvider(mp))
454+
redisClient, err = rueidisotel.NewClient(opts, rueidisotel.WithTracerProvider(tp), rueidisotel.WithMeterProvider(mp))
455+
if err != nil {
456+
return nil, err
457+
}
454458
}
455459
return redisClient, nil
456460
}
@@ -527,7 +531,7 @@ func (a *ConfiguredApp) constructOTELMeterProvider(r *resource.Resource, reg pro
527531

528532
func (a *ConfiguredApp) constructOTELTracingTools(ctx context.Context, r *resource.Resource) (trace.TracerProvider, propagation.TextMapPropagator, func() error, error) {
529533
if !a.isTracingEnabled() {
530-
return trace.NewNoopTracerProvider(), propagation.NewCompositeTextMapPropagator(), func() error { return nil }, nil
534+
return noop.NewTracerProvider(), propagation.NewCompositeTextMapPropagator(), func() error { return nil }, nil
531535
}
532536

533537
// Exporter must be constructed right before TracerProvider as it's started implicitly so needs to be stopped,

cmd/kas/kasapp/router_kas_tunnel_finder.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ var (
2626
ClientStreams: true,
2727
}
2828

29-
// tunnelReadySentinelError is a sentinel error value to make stream visitor exit early.
30-
tunnelReadySentinelError = errors.New("")
29+
// errTunnelReadySentinel is a sentinel error value to make stream visitor exit early.
30+
errTunnelReadySentinel = errors.New("")
3131
)
3232

3333
type kasConnAttempt struct {
@@ -248,15 +248,15 @@ func (f *tunnelFinder) tryKasAsync(ctx context.Context, cancel context.CancelFun
248248
}),
249249
grpctool2.WithCallback(tunnelReadyFieldNumber, func(tunnelReady *GatewayKasResponse_TunnelReady) error {
250250
trace.SpanFromContext(kasStream.Context()).AddEvent("Ready")
251-
return tunnelReadySentinelError
251+
return errTunnelReadySentinel
252252
}),
253253
grpctool2.WithNotExpectingToGet(codes.Internal, headerFieldNumber, messageFieldNumber, trailerFieldNumber, errorFieldNumber),
254254
)
255-
switch err { // nolint:errorlint
256-
case nil:
255+
switch { // nolint:errorlint
256+
case err == nil:
257257
// Gateway kas closed the connection cleanly, perhaps it's been open for too long
258258
return nil, retry.ContinueImmediately
259-
case tunnelReadySentinelError:
259+
case errors.Is(err, errTunnelReadySentinel):
260260
// fallthrough
261261
default:
262262
f.rpcApi.HandleProcessingError(log, f.agentId, "RecvMsg(GatewayKasResponse)", err)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
require (
1515
github.com/alicebob/miniredis/v2 v2.34.0
1616
github.com/ash2k/stager v0.4.0
17+
github.com/coder/websocket v1.8.12
1718
github.com/getsentry/sentry-go v0.31.1
1819
github.com/go-logr/zapr v1.3.0
1920
github.com/golang-jwt/jwt/v5 v5.2.1
@@ -52,7 +53,6 @@ require (
5253
k8s.io/klog/v2 v2.130.1
5354
k8s.io/kubectl v0.32.0
5455
k8s.io/utils v0.0.0-20241210054802-24370beab758
55-
nhooyr.io/websocket v1.8.17
5656
sigs.k8s.io/controller-runtime v0.19.3
5757
sigs.k8s.io/yaml v1.4.0
5858
)

0 commit comments

Comments
 (0)