Merge pull request #621 from abperiasamy/url-type
support string type natively within URLType
This commit is contained in:
+1
-1
@@ -64,7 +64,7 @@ func getNewClient(urlStr string, auth *hostConfig, debug bool) (clnt client.Clie
|
||||
return clnt, err
|
||||
default:
|
||||
return nil, iodine.New(errUnsupportedScheme{
|
||||
scheme: client.GetTypeToString(t),
|
||||
scheme: t.String(),
|
||||
url: urlStr,
|
||||
}, nil)
|
||||
}
|
||||
|
||||
+18
-18
@@ -18,18 +18,30 @@ package client
|
||||
|
||||
import "net/url"
|
||||
|
||||
// Type - enum of different url types
|
||||
type Type int
|
||||
// URLType - enum of different url types
|
||||
type URLType int
|
||||
|
||||
// enum types
|
||||
const (
|
||||
Unknown Type = iota // Unknown type
|
||||
Object // Minio and S3 compatible object storage
|
||||
Filesystem // POSIX compatible file systems
|
||||
Unknown URLType = iota // Unknown type
|
||||
Object // Minio and S3 compatible object storage
|
||||
Filesystem // POSIX compatible file systems
|
||||
)
|
||||
|
||||
// String converts type to string.
|
||||
func (t URLType) String() string {
|
||||
switch t {
|
||||
case Object:
|
||||
return "Object"
|
||||
case Filesystem:
|
||||
return "Filesystem"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// GetType returns the type of URL
|
||||
func GetType(urlStr string) Type {
|
||||
func GetType(urlStr string) URLType {
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return Unknown
|
||||
@@ -41,15 +53,3 @@ func GetType(urlStr string) Type {
|
||||
|
||||
return Filesystem
|
||||
}
|
||||
|
||||
// GetTypeToString returns the type of URL as string
|
||||
func GetTypeToString(t Type) string {
|
||||
switch t {
|
||||
case Object:
|
||||
return "Object"
|
||||
case Filesystem:
|
||||
return "Filesystem"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func getExpandedURL(arg string, aliases map[string]string) (urlStr string, err e
|
||||
}
|
||||
if client.GetType(urlStr) == client.Unknown {
|
||||
return "", iodine.New(errUnsupportedScheme{
|
||||
scheme: client.GetTypeToString(client.Unknown),
|
||||
scheme: client.Unknown.String(),
|
||||
url: urlStr,
|
||||
}, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user