Fixes for new NeoFS layer client

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2020-08-03 18:19:56 +03:00
parent 8101161e51
commit f7dc2095b1

View file

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"crypto/ecdsa"
"net" "net"
"net/http" "net/http"
"time" "time"
@ -14,9 +15,6 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
// should be removed in future
"github.com/minio/minio/legacy"
) )
type ( type (
@ -26,7 +24,7 @@ type (
log *zap.Logger log *zap.Logger
cfg *viper.Viper cfg *viper.Viper
tls *tlsConfig tls *tlsConfig
obj legacy.ObjectLayer obj layer.Client
api api.Handler api api.Handler
conTimeout time.Duration conTimeout time.Duration
@ -52,7 +50,8 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
cli pool.Pool cli pool.Pool
tls *tlsConfig tls *tlsConfig
caller api.Handler caller api.Handler
obj legacy.ObjectLayer obj layer.Client
key *ecdsa.PrivateKey
reBalance = defaultRebalanceTimer reBalance = defaultRebalanceTimer
conTimeout = defaultConnectTimeout conTimeout = defaultConnectTimeout
reqTimeout = defaultRequestTimeout 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)) l.Fatal("failed to initialize auth center", zap.Error(err))
} }
key = center.GetNeoFSPrivateKey()
if v.IsSet(cfgTLSKeyFile) && v.IsSet(cfgTLSCertFile) { if v.IsSet(cfgTLSKeyFile) && v.IsSet(cfgTLSCertFile) {
tls = &tlsConfig{ tls = &tlsConfig{
KeyFile: v.GetString(cfgTLSKeyFile), KeyFile: v.GetString(cfgTLSKeyFile),
@ -97,7 +98,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
Peers: fetchPeers(l, v), Peers: fetchPeers(l, v),
Logger: l, Logger: l,
PrivateKey: center.GetNeoFSPrivateKey(), PrivateKey: key,
GRPCLogger: gRPCLogger(l), GRPCLogger: gRPCLogger(l),
GRPCVerbose: v.GetBool(cfgGRPCVerbose), 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)) 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{ apiParams := handler.Params{
Log: l, Log: l,
Cli: cli, Cli: cli,
Key: center.GetNeoFSPrivateKey(), Key: key,
} }
if caller, err = handler.New(ctx, apiParams); err != nil { if caller, err = handler.New(ctx, apiParams); err != nil {