Merge pull request #1504 from harshavardhana/mc-cp

cp/mirror: URL syntax needs to know if URL is of virtual style
This commit is contained in:
Harshavardhana
2015-11-30 08:19:38 -08:00
3 changed files with 17 additions and 5 deletions
+4 -2
View File
@@ -45,8 +45,10 @@ func checkCopySyntax(ctx *cli.Context) {
url := client.NewURL(tgtURL)
if url.Host != "" {
// This check is for type URL.
if url.Path == string(url.Separator) {
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL))
if !isURLVirtualHostStyle(url.Host) {
if url.Path == string(url.Separator) {
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL))
}
}
}
+5 -3
View File
@@ -75,9 +75,11 @@ func checkMirrorSyntax(ctx *cli.Context) {
url := client.NewURL(tgtURL)
if url.Host != "" {
if url.Path == string(url.Separator) {
fatalIf(errInvalidArgument().Trace(tgtURL),
fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL))
if !isURLVirtualHostStyle(url.Host) {
if url.Path == string(url.Separator) {
fatalIf(errInvalidArgument().Trace(tgtURL),
fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL))
}
}
}
_, _, err = url2Stat(tgtURL)
+8
View File
@@ -17,10 +17,18 @@
package main
import (
"path/filepath"
"github.com/minio/mc/pkg/client"
"github.com/minio/minio-xl/pkg/probe"
)
func isURLVirtualHostStyle(hostURL string) bool {
matchS3, _ := filepath.Match("*.s3*.amazonaws.com", hostURL)
matchGoogle, _ := filepath.Match("*.storage.googleapis.com", hostURL)
return matchS3 || matchGoogle
}
// urlJoinPath Join a path to existing URL.
func urlJoinPath(url1, url2 string) string {
u1 := client.NewURL(url1)