From 8bf8c66371b919e1e65f36bcdb96f9d432f06d4b Mon Sep 17 00:00:00 2001 From: Carter McClellan Date: Tue, 13 Jun 2017 12:30:39 -0700 Subject: [PATCH 1/2] rewritten changes to address issue #2174, and be compatible with Go 1.8 --- cmd/config-host-add.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/config-host-add.go b/cmd/config-host-add.go index b1b4638e9e..0e44c6d2a9 100644 --- a/cmd/config-host-add.go +++ b/cmd/config-host-add.go @@ -17,6 +17,8 @@ package cmd import ( + urlpkg "net/url" + "github.com/fatih/color" "github.com/minio/cli" "github.com/minio/mc/pkg/console" @@ -126,6 +128,16 @@ func mainConfigHostAdd(ctx *cli.Context) error { accessKey := args.Get(2) secretKey := args.Get(3) api := args.Get(4) + + urlHost, _ := urlpkg.Parse(url) + + if isGoogle(urlHost.Host) { + if api == "S3v4" { + fatalIf(errInvalidArgument().Trace(api), "Unsupported API signature for url. Please use `mc config host add "+alias+" "+url+" "+accessKey+" "+secretKey+" S3v2` instead") + } + api = "S3v2" + } + if api == "" { api = "S3v4" } From be85f495ebed55bd7c31fb4052203c97c1743b78 Mon Sep 17 00:00:00 2001 From: CarterMcClellan Date: Tue, 13 Jun 2017 13:53:45 -0700 Subject: [PATCH 2/2] Create config-host-add.go --- cmd/config-host-add.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/config-host-add.go b/cmd/config-host-add.go index 0e44c6d2a9..98f4290ad3 100644 --- a/cmd/config-host-add.go +++ b/cmd/config-host-add.go @@ -129,11 +129,11 @@ func mainConfigHostAdd(ctx *cli.Context) error { secretKey := args.Get(3) api := args.Get(4) - urlHost, _ := urlpkg.Parse(url) + parsedURL, _ := urlpkg.Parse(url) - if isGoogle(urlHost.Host) { + if isGoogle(parsedURL.Host) { if api == "S3v4" { - fatalIf(errInvalidArgument().Trace(api), "Unsupported API signature for url. Please use `mc config host add "+alias+" "+url+" "+accessKey+" "+secretKey+" S3v2` instead") + fatalIf(errInvalidArgument().Trace(api), "Unsupported API signature for url. Please use `mc config host add "+alias+" "+url+" "+accessKey+" "+secretKey+" S3v2` instead.") } api = "S3v2" }