aboutsummaryrefslogtreecommitdiff
path: root/weed/util/parse.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-08 23:57:15 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-08 23:57:15 -0700
commitf6a7e79dc370dfb2e3fe5bff6a380afde95b9a7f (patch)
tree716ffa52d4efe0705789eb6b527f2c370a341f7e /weed/util/parse.go
parent2329d9e0c18aa2dbc2b843a43fe269ee539a0f39 (diff)
downloadseaweedfs-f6a7e79dc370dfb2e3fe5bff6a380afde95b9a7f.tar.xz
seaweedfs-f6a7e79dc370dfb2e3fe5bff6a380afde95b9a7f.zip
weed shell: simplify CLI option for filer
Diffstat (limited to 'weed/util/parse.go')
-rw-r--r--weed/util/parse.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/weed/util/parse.go b/weed/util/parse.go
index 6593d43b6..0955db682 100644
--- a/weed/util/parse.go
+++ b/weed/util/parse.go
@@ -1,6 +1,7 @@
package util
import (
+ "fmt"
"net/url"
"strconv"
"strings"
@@ -45,3 +46,18 @@ func ParseFilerUrl(entryPath string) (filerServer string, filerPort int64, path
path = u.Path
return
}
+
+func ParseHostPort(hostPort string) (filerServer string, filerPort int64, err error) {
+ parts := strings.Split(hostPort, ":")
+ if len(parts) != 2 {
+ err = fmt.Errorf("failed to parse %s\n", hostPort)
+ return
+ }
+
+ filerPort, err = strconv.ParseInt(parts[1], 10, 64)
+ if err == nil {
+ filerServer = parts[0]
+ }
+
+ return
+}