Merge pull request #1181 from abperiasamy/commom-methods-cleanup
target2Client and source2Client methods are not necessary
This commit is contained in:
+2
-2
@@ -170,7 +170,7 @@ func mainAccess(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func doSetAccess(targetURL string, targetPERMS bucketPerms) *probe.Error {
|
||||
clnt, err := target2Client(targetURL)
|
||||
clnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func doSetAccess(targetURL string, targetPERMS bucketPerms) *probe.Error {
|
||||
}
|
||||
|
||||
func doGetAccess(targetURL string) (perms bucketPerms, err *probe.Error) {
|
||||
clnt, err := target2Client(targetURL)
|
||||
clnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return "", err.Trace(targetURL)
|
||||
}
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ func catURL(sourceURL string) *probe.Error {
|
||||
case "-":
|
||||
reader = ioutil.NopCloser(bufio.NewReader(os.Stdin))
|
||||
default:
|
||||
sourceClnt, err := source2Client(URL)
|
||||
sourceClnt, err := url2Client(URL)
|
||||
if err != nil {
|
||||
return err.Trace(URL)
|
||||
}
|
||||
|
||||
+3
-21
@@ -51,7 +51,7 @@ func isTargetURLDir(targetURL string) bool {
|
||||
|
||||
// getSource gets a reader from URL
|
||||
func getSource(sourceURL string) (reader io.ReadCloser, length int64, err *probe.Error) {
|
||||
sourceClnt, err := source2Client(sourceURL)
|
||||
sourceClnt, err := url2Client(sourceURL)
|
||||
if err != nil {
|
||||
return nil, 0, err.Trace()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func getSource(sourceURL string) (reader io.ReadCloser, length int64, err *probe
|
||||
|
||||
// putTarget writes to URL from reader. If length=0, read until EOF.
|
||||
func putTarget(targetURL string, length int64, reader io.Reader) *probe.Error {
|
||||
targetClnt, err := target2Client(targetURL)
|
||||
targetClnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func putTargets(targetURLs []string, length int64, reader io.Reader) *probe.Erro
|
||||
defer close(errCh)
|
||||
|
||||
for _, targetURL := range targetURLs {
|
||||
tgtClient, err := target2Client(targetURL)
|
||||
tgtClient, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
@@ -202,24 +202,6 @@ func url2Client(url string) (client.Client, *probe.Error) {
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// source2Client returns client and hostconfig objects from the source URL.
|
||||
func source2Client(sourceURL string) (client.Client, *probe.Error) {
|
||||
sourceClient, err := url2Client(sourceURL)
|
||||
if err != nil {
|
||||
return nil, err.Trace(sourceURL)
|
||||
}
|
||||
return sourceClient, nil
|
||||
}
|
||||
|
||||
// target2Client returns client and hostconfig objects from the target URL.
|
||||
func target2Client(targetURL string) (client.Client, *probe.Error) {
|
||||
targetClient, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return nil, err.Trace(targetURL)
|
||||
}
|
||||
return targetClient, nil
|
||||
}
|
||||
|
||||
// bucketExists returns error
|
||||
func bucketExists(URL string) *probe.Error {
|
||||
_, _, err := url2Stat(URL)
|
||||
|
||||
@@ -67,15 +67,15 @@ func (s *TestSuite) TestCommonMethods(c *C) {
|
||||
_, _, perr = url2Stat(objectPath + "invalid")
|
||||
c.Assert(perr, Not(IsNil))
|
||||
|
||||
_, perr = source2Client(objectPathServer)
|
||||
_, perr = url2Client(objectPathServer)
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
_, perr = target2Client(objectPathServer)
|
||||
_, perr = url2Client(objectPathServer)
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
_, perr = source2Client("http://test.minio.io" + "/bucket/fail")
|
||||
_, perr = url2Client("http://test.minio.io" + "/bucket/fail")
|
||||
c.Assert(perr, Not(IsNil))
|
||||
|
||||
_, perr = target2Client("http://test.minio.io" + "/bucket/fail")
|
||||
_, perr = url2Client("http://test.minio.io" + "/bucket/fail")
|
||||
c.Assert(perr, Not(IsNil))
|
||||
}
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ func mainList(ctx *cli.Context) {
|
||||
for _, targetURL := range targetURLs {
|
||||
// if recursive strip off the "..."
|
||||
var clnt client.Client
|
||||
clnt, err = target2Client(stripRecursiveURL(targetURL))
|
||||
clnt, err = url2Client(stripRecursiveURL(targetURL))
|
||||
fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.")
|
||||
|
||||
err = doList(clnt, isURLRecursive(targetURL), len(targetURLs) > 1)
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ func mainMakeBucket(ctx *cli.Context) {
|
||||
|
||||
// doMakeBucket -
|
||||
func doMakeBucket(targetURL string) *probe.Error {
|
||||
clnt, err := target2Client(targetURL)
|
||||
clnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func doShareDownloadURL(targetURL string, recursive bool, expires time.Duration)
|
||||
return err.Trace()
|
||||
}
|
||||
var clnt client.Client
|
||||
clnt, err = target2Client(targetURL)
|
||||
clnt, err = url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user