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:
+4
-2
@@ -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
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user