From 83f9be75b74376a9328ca83561719d5cd6dd18ea Mon Sep 17 00:00:00 2001 From: Shamil Ganiev Date: Fri, 27 Dec 2024 19:52:19 +0200 Subject: [PATCH] feat: replace deprecated grpc.Dial by grpc.NewClient --- internal/provider/provider.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 6909a0e..4555a8c 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -367,7 +367,7 @@ func GetToken(clientID, clientSecret, tokenURL, audience string) (*oauth2.Token, // CreateAuthenticatedClient creates a gRPC client with OAuth authentication. func CreateAuthenticatedClient(endpoint string, token *oauth2.Token, credentials grpcCreds.TransportCredentials) (*grpc.ClientConn, error) { - return grpc.Dial(endpoint, grpc.WithTransportCredentials(credentials), grpc.WithUnaryInterceptor( + return grpc.NewClient(endpoint, grpc.WithTransportCredentials(credentials), grpc.WithUnaryInterceptor( func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { newCtx := metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token.AccessToken) return invoker(newCtx, method, req, reply, cc, opts...) @@ -377,12 +377,12 @@ func CreateAuthenticatedClient(endpoint string, token *oauth2.Token, credentials // CreateSecureClient creates a gRPC client using mTLS without OAuth authentication. func CreateSecureClient(endpoint string, credentials grpcCreds.TransportCredentials) (*grpc.ClientConn, error) { - return grpc.Dial(endpoint, grpc.WithTransportCredentials(credentials)) + return grpc.NewClient(endpoint, grpc.WithTransportCredentials(credentials)) } // CreateInsecureClient creates a gRPC client without any authentication. func CreateInsecureClient(endpoint string, credentials grpcCreds.TransportCredentials) (*grpc.ClientConn, error) { - return grpc.Dial(endpoint, grpc.WithTransportCredentials(credentials)) + return grpc.NewClient(endpoint, grpc.WithTransportCredentials(credentials)) } // CreateGRPCClient decides which gRPC client to create based on clientID.