From 4b8820230d47bd3c7ec3c387296371bcb937e3cc Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Tue, 30 Jul 2019 20:49:01 +0300 Subject: [PATCH] Initialize correctly libuplink for `uplink setup` and `gateway setup` (#2662) --- cmd/gateway/main.go | 23 ++++++++++++++++------- cmd/uplink/cmd/setup.go | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index f81d6775d..9ef0e2f3a 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -253,24 +253,33 @@ func (flags GatewayFlags) NewGateway(ctx context.Context) (gw minio.Gateway, err ), nil } -func (flags GatewayFlags) openProject(ctx context.Context) (*libuplink.Project, error) { - cfg := libuplink.Config{} - cfg.Volatile.TLS = struct { +func (flags *GatewayFlags) newUplink(ctx context.Context) (*libuplink.Uplink, error) { + // Transform the gateway config flags to the libuplink config object + libuplinkCfg := &libuplink.Config{} + libuplinkCfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize + libuplinkCfg.Volatile.MaxMemory = flags.RS.MaxBufferMem + libuplinkCfg.Volatile.PeerIDVersion = flags.TLS.PeerIDVersions + libuplinkCfg.Volatile.TLS = struct { SkipPeerCAWhitelist bool PeerCAWhitelistPath string }{ SkipPeerCAWhitelist: !flags.TLS.UsePeerCAWhitelist, PeerCAWhitelistPath: flags.TLS.PeerCAWhitelistPath, } - cfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize - cfg.Volatile.MaxMemory = flags.RS.MaxBufferMem + libuplinkCfg.Volatile.DialTimeout = flags.Client.DialTimeout + libuplinkCfg.Volatile.RequestTimeout = flags.Client.RequestTimeout + + return libuplink.NewUplink(ctx, libuplinkCfg) +} + +func (flags GatewayFlags) openProject(ctx context.Context) (*libuplink.Project, error) { apiKey, err := libuplink.ParseAPIKey(flags.Client.APIKey) if err != nil { return nil, err } - uplk, err := libuplink.NewUplink(ctx, &cfg) + uplk, err := flags.newUplink(ctx) if err != nil { return nil, err } @@ -307,7 +316,7 @@ func (flags GatewayFlags) interactive( return Error.Wrap(err) } - uplk, err := libuplink.NewUplink(ctx, nil) + uplk, err := flags.newUplink(ctx) if err != nil { return Error.Wrap(err) } diff --git a/cmd/uplink/cmd/setup.go b/cmd/uplink/cmd/setup.go index e3b5bcacf..4e1ebbf55 100644 --- a/cmd/uplink/cmd/setup.go +++ b/cmd/uplink/cmd/setup.go @@ -129,7 +129,7 @@ func cmdSetupInteractive(cmd *cobra.Command, setupDir string, encryptionKeyFilep return Error.Wrap(err) } - uplk, err := libuplink.NewUplink(ctx, nil) + uplk, err := setupCfg.NewUplink(ctx) if err != nil { return Error.Wrap(err) }