diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-02-26 16:46:01 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-02-26 16:46:01 -0800 |
| commit | 0156e2975aa4aabe142301deb72cc2657eb79ee9 (patch) | |
| tree | 191e0a3c65964fa75c3cdc661aefdab16e97e3a2 /weed/filesys/wfs.go | |
| parent | 543cf1c80e222f3ff4be5fcfa88d2a7e9c868de2 (diff) | |
| download | seaweedfs-0156e2975aa4aabe142301deb72cc2657eb79ee9.tar.xz seaweedfs-0156e2975aa4aabe142301deb72cc2657eb79ee9.zip | |
mount: add mode to run external to SeaweedFS container cluster
Diffstat (limited to 'weed/filesys/wfs.go')
| -rw-r--r-- | weed/filesys/wfs.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 8f4225fb0..aa530f6aa 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -5,6 +5,7 @@ import ( "fmt" "math" "os" + "strings" "sync" "time" @@ -37,6 +38,9 @@ type Option struct { MountMode os.FileMode MountCtime time.Time MountMtime time.Time + + // whether the mount runs outside SeaweedFS containers + OutsideContainerClusterMode bool } var _ = fs.FS(&WFS{}) @@ -247,5 +251,17 @@ func (wfs *WFS) forgetNode(fullpath filer2.FullPath) { defer wfs.nodesLock.Unlock() delete(wfs.nodes, fullpath.AsInode()) +} + +func (wfs *WFS) AdjustedUrl(hostAndPort string) string { + if !wfs.option.OutsideContainerClusterMode { + return hostAndPort + } + commaIndex := strings.Index(hostAndPort, ":") + if commaIndex < 0 { + return hostAndPort + } + filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":") + return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], hostAndPort[commaIndex+1:]) } |
