diff options
Diffstat (limited to 'weed/command/mount.go')
| -rw-r--r-- | weed/command/mount.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/weed/command/mount.go b/weed/command/mount.go index 8d026feac..d35723c15 100644 --- a/weed/command/mount.go +++ b/weed/command/mount.go @@ -1,5 +1,11 @@ package command +import ( + "strings" + "fmt" + "strconv" +) + type MountOptions struct { filer *string filerGrpcPort *int @@ -46,3 +52,22 @@ var cmdMount = &Command{ `, } + +func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress string, err error) { + hostnameAndPort := strings.Split(filer, ":") + if len(hostnameAndPort) != 2 { + return "", fmt.Errorf("The filer should have hostname:port format: %v", hostnameAndPort) + } + + filerPort, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64) + if parseErr != nil { + return "", fmt.Errorf("The filer filer port parse error: %v", parseErr) + } + + filerGrpcPort := int(filerPort) + 10000 + if optionalGrpcPort != 0 { + filerGrpcPort = optionalGrpcPort + } + + return fmt.Sprintf("%s:%d", hostnameAndPort[0], filerGrpcPort), nil +} |
