From 504e427c181fa55e614f4c42d1e2b933dfabddf2 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sat, 17 Sep 2022 10:41:31 +0400 Subject: [PATCH] [#417] rpc/client: Do not use deprecated code elements `grpc.WithInsecure` has been marked as deprecated in earlier releases of `google.golang.org/grpc`. Use `google.golang.org/grpc/credentials/insecure` package instead as recommended. Signed-off-by: Leonard Lyubich --- rpc/client/connect.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rpc/client/connect.go b/rpc/client/connect.go index 8b7db4f..18134c4 100644 --- a/rpc/client/connect.go +++ b/rpc/client/connect.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc" grpcstd "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) func (c *Client) createGRPCClient() (err error) { @@ -38,19 +39,17 @@ func (c *Client) openGRPCConn() error { return errInvalidEndpoint } - var err error - - var credOpt grpcstd.DialOption + var creds credentials.TransportCredentials if c.tlsCfg != nil { - creds := credentials.NewTLS(c.tlsCfg) - credOpt = grpcstd.WithTransportCredentials(creds) + creds = credentials.NewTLS(c.tlsCfg) } else { - credOpt = grpcstd.WithInsecure() + creds = insecure.NewCredentials() } dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout) - c.conn, err = grpcstd.DialContext(dialCtx, c.addr, credOpt) + var err error + c.conn, err = grpcstd.DialContext(dialCtx, c.addr, grpcstd.WithTransportCredentials(creds)) cancel() return err