diff options
| author | Viktor Kuzmin <kvaster@gmail.com> | 2023-08-07 10:47:02 +0300 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2023-08-07 10:22:05 -0700 |
| commit | 44d2cf555cf470e9fe689976b8f55f6be2730ab5 (patch) | |
| tree | 40da9a7339f62bab8e10a19f8104acad58b01e6c /pkg/driver | |
| parent | 8f9751354db37dc26b1d6662f2f853752e0c4479 (diff) | |
| download | seaweedfs-csi-driver-44d2cf555cf470e9fe689976b8f55f6be2730ab5.tar.xz seaweedfs-csi-driver-44d2cf555cf470e9fe689976b8f55f6be2730ab5.zip | |
gofmt of mounter_seaweedfs
Diffstat (limited to 'pkg/driver')
| -rw-r--r-- | pkg/driver/mounter_seaweedfs.go | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/pkg/driver/mounter_seaweedfs.go b/pkg/driver/mounter_seaweedfs.go index 6625089..5072b49 100644 --- a/pkg/driver/mounter_seaweedfs.go +++ b/pkg/driver/mounter_seaweedfs.go @@ -70,39 +70,39 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { } // Handle volumeCapacity from controllerserver.go:51 - if value, ok := seaweedFs.volContext["volumeCapacity"]; ok{ + if value, ok := seaweedFs.volContext["volumeCapacity"]; ok { capacityMB := parseVolumeCapacity(value) args = append(args, fmt.Sprintf("-collectionQuotaMB=%d", capacityMB)) } // Values for override-able args // Whitelist for merging with volContext - argsMap := map[string]string { - "collection": seaweedFs.collection, - "filer": strings.Join(filers, ","), - "filer.path": seaweedFs.path, - "cacheCapacityMB": fmt.Sprint(seaweedFs.driver.CacheCapacityMB), - "concurrentWriters": fmt.Sprint(seaweedFs.driver.ConcurrentWriters), - "map.uid": seaweedFs.driver.UidMap, - "map.gid": seaweedFs.driver.GidMap, - "disk": "", - "dataCenter": "", - "replication": "", - "ttl": "", - "chunkSizeLimitMB": "", - "volumeServerAccess": "", - "readRetryTime": "", + argsMap := map[string]string{ + "collection": seaweedFs.collection, + "filer": strings.Join(filers, ","), + "filer.path": seaweedFs.path, + "cacheCapacityMB": fmt.Sprint(seaweedFs.driver.CacheCapacityMB), + "concurrentWriters": fmt.Sprint(seaweedFs.driver.ConcurrentWriters), + "map.uid": seaweedFs.driver.UidMap, + "map.gid": seaweedFs.driver.GidMap, + "disk": "", + "dataCenter": "", + "replication": "", + "ttl": "", + "chunkSizeLimitMB": "", + "volumeServerAccess": "", + "readRetryTime": "", } // Handle DataLocality - dataLocality := seaweedFs.driver.DataLocality; + dataLocality := seaweedFs.driver.DataLocality // Try to override when set in context - if dataLocalityStr, ok := seaweedFs.volContext["dataLocality"]; ok{ + if dataLocalityStr, ok := seaweedFs.volContext["dataLocality"]; ok { // Convert to enum dataLocalityRes, ok := datalocality.FromString(dataLocalityStr) - if(!ok){ - glog.Warning("volumeContext 'dataLocality' invalid"); - }else{ + if !ok { + glog.Warning("volumeContext 'dataLocality' invalid") + } else { dataLocality = dataLocalityRes } } @@ -110,18 +110,18 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { return nil, err } // Settings based on type - switch(dataLocality){ + switch dataLocality { case datalocality.Write_preferLocalDc: - argsMap["dataCenter"] = seaweedFs.driver.DataCenter; + argsMap["dataCenter"] = seaweedFs.driver.DataCenter } // volContext-parameter -> mount-arg parameterArgMap := map[string]string{ - "uidMap": "map.uid", - "gidMap": "map.gid", - "filerPath": "filer.path", + "uidMap": "map.uid", + "gidMap": "map.gid", + "filerPath": "filer.path", // volumeContext has "diskType", but mount-option is "disk", converting for backwards compatability - "diskType": "disk", + "diskType": "disk", } // Explicitly ignored volContext args e.g. handled somewhere else @@ -132,11 +132,13 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { // Merge volContext into argsMap with key-mapping for arg, value := range seaweedFs.volContext { - if(in_arr(ignoreArgs, arg)){continue} + if in_arr(ignoreArgs, arg) { + continue + } // Check if key-mapping exists newArg, ok := parameterArgMap[arg] - if(ok){ + if ok { arg = newArg } @@ -151,8 +153,8 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { } // Convert Args-Map to args - for arg, value := range argsMap{ - if(value != ""){ // ignore empty values + for arg, value := range argsMap { + if value != "" { // ignore empty values args = append(args, fmt.Sprintf("-%s=%s", arg, value)) } } @@ -199,7 +201,7 @@ func parseVolumeCapacity(volumeCapacity string) int64 { func in_arr(arr []string, val string) bool { for _, v := range arr { - if(val == v) { + if val == v { return true } } |
