forked from TrueCloudLab/frostfs-api-go
[#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 <leonard@nspcc.ru>
This commit is contained in:
parent
49bf6b24b0
commit
504e427c18
1 changed files with 6 additions and 7 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
|
||||||
grpcstd "google.golang.org/grpc"
|
grpcstd "google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) createGRPCClient() (err error) {
|
func (c *Client) createGRPCClient() (err error) {
|
||||||
|
@ -38,19 +39,17 @@ func (c *Client) openGRPCConn() error {
|
||||||
return errInvalidEndpoint
|
return errInvalidEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var creds credentials.TransportCredentials
|
||||||
|
|
||||||
var credOpt grpcstd.DialOption
|
|
||||||
|
|
||||||
if c.tlsCfg != nil {
|
if c.tlsCfg != nil {
|
||||||
creds := credentials.NewTLS(c.tlsCfg)
|
creds = credentials.NewTLS(c.tlsCfg)
|
||||||
credOpt = grpcstd.WithTransportCredentials(creds)
|
|
||||||
} else {
|
} else {
|
||||||
credOpt = grpcstd.WithInsecure()
|
creds = insecure.NewCredentials()
|
||||||
}
|
}
|
||||||
|
|
||||||
dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout)
|
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()
|
cancel()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue