diff --git a/common-methods.go b/common-methods.go index babe68f9..5d1f6327 100644 --- a/common-methods.go +++ b/common-methods.go @@ -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) } diff --git a/pkg/client/url.go b/pkg/client/url.go index 777e7cf0..3db47f0c 100644 --- a/pkg/client/url.go +++ b/pkg/client/url.go @@ -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" - } -} diff --git a/url.go b/url.go index c177321d..454c1a9c 100644 --- a/url.go +++ b/url.go @@ -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) }