mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor and fix strings.Split
This commit is contained in:
parent
1a4bf0dcb5
commit
67814a5c79
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/seaweedfs/seaweedfs/weed/security"
|
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ func doFilerBackup(grpcDialOption grpc.DialOption, backupOption *FilerBackupOpti
|
||||||
|
|
||||||
sourceFiler := pb.ServerAddress(*backupOption.filer)
|
sourceFiler := pb.ServerAddress(*backupOption.filer)
|
||||||
sourcePath := *backupOption.path
|
sourcePath := *backupOption.path
|
||||||
excludePaths := strings.Split(*backupOption.excludePaths, ",")
|
excludePaths := util.StringSplit(*backupOption.excludePaths, ",")
|
||||||
timeAgo := *backupOption.timeAgo
|
timeAgo := *backupOption.timeAgo
|
||||||
targetPath := dataSink.GetSinkToDirectory()
|
targetPath := dataSink.GetSinkToDirectory()
|
||||||
debug := *backupOption.debug
|
debug := *backupOption.debug
|
||||||
|
|
|
@ -143,7 +143,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
|
||||||
grpcDialOption,
|
grpcDialOption,
|
||||||
filerA,
|
filerA,
|
||||||
*syncOptions.aPath,
|
*syncOptions.aPath,
|
||||||
util.Split(*syncOptions.aExcludePaths, ","),
|
util.StringSplit(*syncOptions.aExcludePaths, ","),
|
||||||
*syncOptions.aProxyByFiler,
|
*syncOptions.aProxyByFiler,
|
||||||
filerB,
|
filerB,
|
||||||
*syncOptions.bPath,
|
*syncOptions.bPath,
|
||||||
|
@ -179,7 +179,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
|
||||||
grpcDialOption,
|
grpcDialOption,
|
||||||
filerB,
|
filerB,
|
||||||
*syncOptions.bPath,
|
*syncOptions.bPath,
|
||||||
util.Split(*syncOptions.bExcludePaths, ","),
|
util.StringSplit(*syncOptions.bExcludePaths, ","),
|
||||||
*syncOptions.bProxyByFiler,
|
*syncOptions.bProxyByFiler,
|
||||||
filerA,
|
filerA,
|
||||||
*syncOptions.aPath,
|
*syncOptions.aPath,
|
||||||
|
|
|
@ -113,10 +113,7 @@ func runMaster(cmd *Command, args []string) bool {
|
||||||
glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err)
|
glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var masterWhiteList []string
|
masterWhiteList := util.StringSplit(*m.whiteList, ",")
|
||||||
if *m.whiteList != "" {
|
|
||||||
masterWhiteList = strings.Split(*m.whiteList, ",")
|
|
||||||
}
|
|
||||||
if *m.volumeSizeLimitMB > util.VolumeSizeLimitGB*1000 {
|
if *m.volumeSizeLimitMB > util.VolumeSizeLimitGB*1000 {
|
||||||
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,6 @@ var (
|
||||||
isStartingWebDav = cmdServer.Flag.Bool("webdav", false, "whether to start WebDAV gateway")
|
isStartingWebDav = cmdServer.Flag.Bool("webdav", false, "whether to start WebDAV gateway")
|
||||||
isStartingMqBroker = cmdServer.Flag.Bool("mq.broker", false, "whether to start message queue broker")
|
isStartingMqBroker = cmdServer.Flag.Bool("mq.broker", false, "whether to start message queue broker")
|
||||||
|
|
||||||
serverWhiteList []string
|
|
||||||
|
|
||||||
False = false
|
False = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -248,9 +246,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
}
|
}
|
||||||
filerOptions.defaultLevelDbDirectory = masterOptions.metaFolder
|
filerOptions.defaultLevelDbDirectory = masterOptions.metaFolder
|
||||||
|
|
||||||
if *serverWhiteListOption != "" {
|
serverWhiteList := util.StringSplit(*serverWhiteListOption, ",")
|
||||||
serverWhiteList = strings.Split(*serverWhiteListOption, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
if *isStartingFiler {
|
if *isStartingFiler {
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -188,9 +188,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
|
||||||
}
|
}
|
||||||
|
|
||||||
// security related white list configuration
|
// security related white list configuration
|
||||||
if volumeWhiteListOption != "" {
|
v.whiteList = util.StringSplit(volumeWhiteListOption, ",")
|
||||||
v.whiteList = strings.Split(volumeWhiteListOption, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
if *v.ip == "" {
|
if *v.ip == "" {
|
||||||
*v.ip = util.DetectedHostAddress()
|
*v.ip = util.DetectedHostAddress()
|
||||||
|
|
|
@ -3,6 +3,7 @@ package s3api
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -43,7 +44,7 @@ func FromTags(tags map[string]string) (t *Tagging) {
|
||||||
|
|
||||||
func parseTagsHeader(tags string) (map[string]string, error) {
|
func parseTagsHeader(tags string) (map[string]string, error) {
|
||||||
parsedTags := make(map[string]string)
|
parsedTags := make(map[string]string)
|
||||||
for _, v := range strings.Split(tags, "&") {
|
for _, v := range util.StringSplit(tags, "&") {
|
||||||
tag := strings.Split(v, "=")
|
tag := strings.Split(v, "=")
|
||||||
if len(tag) == 2 {
|
if len(tag) == 2 {
|
||||||
parsedTags[tag[0]] = tag[1]
|
parsedTags[tag[0]] = tag[1]
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util/grace"
|
"github.com/seaweedfs/seaweedfs/weed/util/grace"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
"io"
|
"io"
|
||||||
|
@ -100,7 +101,7 @@ https://cloud.seaweedfs.com/ui/%s
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range strings.Split(cmd, ";") {
|
for _, c := range util.StringSplit(cmd, ";") {
|
||||||
if processEachCmd(reg, c, commandEnv) {
|
if processEachCmd(reg, c, commandEnv) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (fp FullPath) IsUnder(other FullPath) bool {
|
||||||
return strings.HasPrefix(string(fp), string(other)+"/")
|
return strings.HasPrefix(string(fp), string(other)+"/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Split(separatedValues string, sep string) []string {
|
func StringSplit(separatedValues string, sep string) []string {
|
||||||
if separatedValues == "" {
|
if separatedValues == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue