Skip to content

Commit

Permalink
Replace grpc.WithInsecure()
Browse files Browse the repository at this point in the history
grpc.WithInsecure() has been deprecated and our linter is screaming
about it. I've replaced it with the new way which is
grpc.WithTransportCredentials(insecure.NewCredentials).

Signed-off-by: Jesus Vazquez <jesus.vazquez@grafana.com>
  • Loading branch information
jesusvazquez committed Apr 13, 2022
1 parent cd0540f commit 860792b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/ingester/client/mimir_util_test.go
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
)

Expand All @@ -29,7 +30,7 @@ func TestSendQueryStream(t *testing.T) {
return listen.Dial()
}

conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure())
conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
defer conn.Close()

Expand Down
3 changes: 2 additions & 1 deletion pkg/mimir/mimir_test.go
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/weaveworks/common/server"
"go.uber.org/atomic"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/grafana/mimir/pkg/alertmanager"
"github.com/grafana/mimir/pkg/alertmanager/alertstore"
Expand Down Expand Up @@ -362,7 +363,7 @@ func TestGrpcAuthMiddleware(t *testing.T) {
}()
}

conn, err := grpc.Dial(net.JoinHostPort(cfg.Server.GRPCListenAddress, strconv.Itoa(cfg.Server.GRPCListenPort)), grpc.WithInsecure())
conn, err := grpc.Dial(net.JoinHostPort(cfg.Server.GRPCListenAddress, strconv.Itoa(cfg.Server.GRPCListenPort)), grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
defer func() {
require.NoError(t, conn.Close())
Expand Down
5 changes: 3 additions & 2 deletions pkg/querier/worker/frontend_processor_test.go
Expand Up @@ -16,14 +16,15 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

func TestRecvFailDoesntCancelProcess(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// We use random port here, hopefully without any gRPC server.
cc, err := grpc.DialContext(ctx, "localhost:999", grpc.WithInsecure())
cc, err := grpc.DialContext(ctx, "localhost:999", grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)

cfg := Config{}
Expand Down Expand Up @@ -56,7 +57,7 @@ func TestContextCancelStopsProcess(t *testing.T) {
defer cancel()

// We use random port here, hopefully without any gRPC server.
cc, err := grpc.DialContext(ctx, "localhost:999", grpc.WithInsecure())
cc, err := grpc.DialContext(ctx, "localhost:999", grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)

pm := newProcessorManager(ctx, &mockProcessor{}, cc, "test")
Expand Down
3 changes: 2 additions & 1 deletion pkg/scheduler/scheduler_test.go
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/uber/jaeger-client-go/config"
"github.com/weaveworks/common/httpgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/grafana/mimir/pkg/frontend/v2/frontendv2pb"
"github.com/grafana/mimir/pkg/scheduler/schedulerpb"
Expand Down Expand Up @@ -62,7 +63,7 @@ func setupScheduler(t *testing.T, reg prometheus.Registerer) (*Scheduler, schedu
_ = l.Close()
})

c, err := grpc.Dial(l.Addr().String(), grpc.WithInsecure())
c, err := grpc.Dial(l.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)

t.Cleanup(func() {
Expand Down

0 comments on commit 860792b

Please sign in to comment.