From f7dc2095b1b51ec81bfe73fda586fe5929d78b9e Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Mon, 3 Aug 2020 18:19:56 +0300 Subject: [PATCH] Fixes for new NeoFS layer client Signed-off-by: Evgeniy Kulikov --- cmd/gate/app.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/gate/app.go b/cmd/gate/app.go index 1cf592d5..e81e7454 100644 --- a/cmd/gate/app.go +++ b/cmd/gate/app.go @@ -2,6 +2,7 @@ package main import ( "context" + "crypto/ecdsa" "net" "net/http" "time" @@ -14,9 +15,6 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" "google.golang.org/grpc/keepalive" - - // should be removed in future - "github.com/minio/minio/legacy" ) type ( @@ -26,7 +24,7 @@ type ( log *zap.Logger cfg *viper.Viper tls *tlsConfig - obj legacy.ObjectLayer + obj layer.Client api api.Handler conTimeout time.Duration @@ -52,7 +50,8 @@ func newApp(l *zap.Logger, v *viper.Viper) *App { cli pool.Pool tls *tlsConfig caller api.Handler - obj legacy.ObjectLayer + obj layer.Client + key *ecdsa.PrivateKey reBalance = defaultRebalanceTimer conTimeout = defaultConnectTimeout reqTimeout = defaultRequestTimeout @@ -66,6 +65,8 @@ func newApp(l *zap.Logger, v *viper.Viper) *App { l.Fatal("failed to initialize auth center", zap.Error(err)) } + key = center.GetNeoFSPrivateKey() + if v.IsSet(cfgTLSKeyFile) && v.IsSet(cfgTLSCertFile) { tls = &tlsConfig{ KeyFile: v.GetString(cfgTLSKeyFile), @@ -97,7 +98,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App { Peers: fetchPeers(l, v), Logger: l, - PrivateKey: center.GetNeoFSPrivateKey(), + PrivateKey: key, GRPCLogger: gRPCLogger(l), GRPCVerbose: v.GetBool(cfgGRPCVerbose), @@ -125,7 +126,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App { } } - if obj, err = layer.NewLayer(l, cli, center); err != nil { + if obj, err = layer.NewLayer(l, cli, key); err != nil { l.Fatal("could not prepare ObjectLayer", zap.Error(err)) } @@ -136,7 +137,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App { apiParams := handler.Params{ Log: l, Cli: cli, - Key: center.GetNeoFSPrivateKey(), + Key: key, } if caller, err = handler.New(ctx, apiParams); err != nil {