fix master maintenance logic

Signed-off-by: Lei Liu <lei01.liu@horizon.ai>
This commit is contained in:
Lei Liu
2019-11-12 14:21:43 +08:00
parent ee90236a97
commit 46755ea1e1
8 changed files with 50 additions and 42 deletions

View File

@@ -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
}