Make getURL - getExpandedURL
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ func runAccessCmd(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
targetURLs, err := getURLs(ctx.Args(), config.Aliases)
|
||||
targetURLs, err := getExpandedURLs(ctx.Args(), config.Aliases)
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ func runCatCmd(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
// Convert arguments to URLs: expand alias, fix format...
|
||||
urls, err := getURLs(ctx.Args(), config.Aliases)
|
||||
urls, err := getExpandedURLs(ctx.Args(), config.Aliases)
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
|
||||
@@ -37,7 +37,7 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
// Convert arguments to URLs: expand alias, fix format...
|
||||
urls, err := getURLs(ctx.Args(), config.Aliases)
|
||||
urls, err := getExpandedURLs(ctx.Args(), config.Aliases)
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
|
||||
@@ -39,7 +39,7 @@ func runListCmd(ctx *cli.Context) {
|
||||
}
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
for _, arg := range ctx.Args() {
|
||||
targetURL, err := getURL(arg, config.Aliases)
|
||||
targetURL, err := getExpandedURL(arg, config.Aliases)
|
||||
if err != nil {
|
||||
switch iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
|
||||
@@ -38,7 +38,7 @@ func runMakeBucketCmd(ctx *cli.Context) {
|
||||
console.Fatalf("Unable to read config file [%s].\n", mustGetMcConfigPath())
|
||||
}
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
targetURLs, err := getURLs(ctx.Args(), config.Aliases)
|
||||
targetURLs, err := getExpandedURLs(ctx.Args(), config.Aliases)
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
|
||||
+16
-16
@@ -48,7 +48,7 @@ var _ = Suite(&CmdTestSuite{})
|
||||
|
||||
func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) {
|
||||
methods := &MockclientMethods{}
|
||||
sourceURL, err := getURL("foo", nil)
|
||||
sourceURL, err := getExpandedURL("foo", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
data := "Hello World"
|
||||
@@ -56,7 +56,7 @@ func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) {
|
||||
hexMd5 := hex.EncodeToString(md5Sum[:])
|
||||
dataLength := int64(len(data))
|
||||
|
||||
targetURL, err := getURL("bar", nil)
|
||||
targetURL, err := getExpandedURL("bar", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
sourceReader, sourceWriter := io.Pipe()
|
||||
@@ -93,10 +93,10 @@ func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCopyRecursive(c *C) {
|
||||
sourceURL, err := getURL("http://example.com/bucket1/", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com/bucket1/", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
targetURL, err := getURL("http://example.com/bucket2/", nil)
|
||||
targetURL, err := getExpandedURL("http://example.com/bucket2/", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -192,10 +192,10 @@ func (c *failClose) Close() error {
|
||||
|
||||
func (s *CmdTestSuite) TestCopyCmdFailures(c *C) {
|
||||
methods := &MockclientMethods{}
|
||||
sourceURL, err := getURL("foo", nil)
|
||||
sourceURL, err := getExpandedURL("foo", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
targetURL, err := getURL("bar", nil)
|
||||
targetURL, err := getExpandedURL("bar", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
var nilReadCloser io.ReadCloser
|
||||
@@ -269,7 +269,7 @@ func (s *CmdTestSuite) TestCopyCmdFailures(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestLsCmdWithBucket(c *C) {
|
||||
sourceURL, err := getURL("http://example.com/bucket1/", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com/bucket1/", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -312,7 +312,7 @@ func (s *CmdTestSuite) TestLsCmdWithBucket(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestLsCmdWithFilePath(c *C) {
|
||||
sourceURL, err := getURL("foo", nil)
|
||||
sourceURL, err := getExpandedURL("foo", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -356,7 +356,7 @@ func (s *CmdTestSuite) TestLsCmdWithFilePath(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestLsCmdListsBuckets(c *C) {
|
||||
sourceURL, err := getURL("http://example.com", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -393,7 +393,7 @@ func (s *CmdTestSuite) TestLsCmdListsBuckets(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestMbCmd(c *C) {
|
||||
sourceURL, err := getURL("http://example.com/bucket1", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com/bucket1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -416,7 +416,7 @@ func (s *CmdTestSuite) TestMbCmd(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestMbCmdFailures(c *C) {
|
||||
sourceURL, err := getURL("http://example.com/bucket1", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com/bucket1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -461,7 +461,7 @@ func (s *CmdTestSuite) TestMbCmdFailures(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestMbCmdOnFile(c *C) {
|
||||
sourceURL, err := getURL("bucket1", nil)
|
||||
sourceURL, err := getExpandedURL("bucket1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -484,9 +484,9 @@ func (s *CmdTestSuite) TestMbCmdOnFile(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCatCmdObject(c *C) {
|
||||
sourceURL, err := getURL("http://example.com/bucket1/object1", nil)
|
||||
sourceURL, err := getExpandedURL("http://example.com/bucket1/object1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
targetURL, err := getURL("object1", nil)
|
||||
targetURL, err := getExpandedURL("object1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
@@ -537,9 +537,9 @@ func (s *CmdTestSuite) TestCatCmdObject(c *C) {
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCatCmdFile(c *C) {
|
||||
sourceURL, err := getURL("object1", nil)
|
||||
sourceURL, err := getExpandedURL("object1", nil)
|
||||
c.Assert(err, IsNil)
|
||||
targetURL, err := getURL("object2", nil)
|
||||
targetURL, err := getExpandedURL("object2", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
methods := &MockclientMethods{}
|
||||
|
||||
@@ -35,8 +35,8 @@ func isURLRecursive(urlStr string) bool {
|
||||
return strings.HasSuffix(urlStr, recursiveSeparator)
|
||||
}
|
||||
|
||||
// getURL - extracts URL string from a single cmd-line argument
|
||||
func getURL(arg string, aliases map[string]string) (urlStr string, err error) {
|
||||
// getExpandedURL - extracts URL string from a single cmd-line argument
|
||||
func getExpandedURL(arg string, aliases map[string]string) (urlStr string, err error) {
|
||||
_, err = url.Parse(arg)
|
||||
if err != nil {
|
||||
// Not a valid URL. Return error
|
||||
@@ -56,10 +56,10 @@ func getURL(arg string, aliases map[string]string) (urlStr string, err error) {
|
||||
return urlStr, nil
|
||||
}
|
||||
|
||||
// getURLs - extracts multiple URL strings from a single cmd-line argument
|
||||
func getURLs(args []string, aliases map[string]string) (urls []string, err error) {
|
||||
// getExpandedURLs - extracts multiple URL strings from a single cmd-line argument
|
||||
func getExpandedURLs(args []string, aliases map[string]string) (urls []string, err error) {
|
||||
for _, arg := range args {
|
||||
u, err := getURL(arg, aliases)
|
||||
u, err := getExpandedURL(arg, aliases)
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user