aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
authorLei Liu <lei01.liu@horizon.ai>2019-11-12 14:21:43 +0800
committerLei Liu <lei01.liu@horizon.ai>2019-11-12 14:46:10 +0800
commit46755ea1e1e4d79e4c0368aa7fcb17ee8aa812cc (patch)
tree616583cdfdd2803465345fee4ee4cdbcba5f72aa /weed/util
parentee90236a972acea8722dccfa1b04926d551fc82d (diff)
downloadseaweedfs-46755ea1e1e4d79e4c0368aa7fcb17ee8aa812cc.tar.xz
seaweedfs-46755ea1e1e4d79e4c0368aa7fcb17ee8aa812cc.zip
fix master maintenance logic
Signed-off-by: Lei Liu <lei01.liu@horizon.ai>
Diffstat (limited to 'weed/util')
-rw-r--r--weed/util/config.go1
-rw-r--r--weed/util/parse.go21
2 files changed, 21 insertions, 1 deletions
diff --git a/weed/util/config.go b/weed/util/config.go
index 7e2f9b373..0ace53a37 100644
--- a/weed/util/config.go
+++ b/weed/util/config.go
@@ -45,4 +45,3 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
func Config() Configuration {
return viper.GetViper()
}
-
diff --git a/weed/util/parse.go b/weed/util/parse.go
index 0a8317c19..6593d43b6 100644
--- a/weed/util/parse.go
+++ b/weed/util/parse.go
@@ -1,7 +1,9 @@
package util
import (
+ "net/url"
"strconv"
+ "strings"
)
func ParseInt(text string, defaultValue int) int {
@@ -24,3 +26,22 @@ func ParseUint64(text string, defaultValue uint64) uint64 {
}
return count
}
+
+func ParseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
+ if !strings.HasPrefix(entryPath, "http://") && !strings.HasPrefix(entryPath, "https://") {
+ entryPath = "http://" + entryPath
+ }
+
+ var u *url.URL
+ u, err = url.Parse(entryPath)
+ if err != nil {
+ return
+ }
+ filerServer = u.Hostname()
+ portString := u.Port()
+ if portString != "" {
+ filerPort, err = strconv.ParseInt(portString, 10, 32)
+ }
+ path = u.Path
+ return
+}