提交 3783b6c0 编写于 作者: martianzhang's avatar martianzhang

regression filepath.Join

  compatible with windows file path, regression filepath.Join
上级 e6a710de
...@@ -25,7 +25,6 @@ import ( ...@@ -25,7 +25,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"regexp" "regexp"
"runtime" "runtime"
"strings" "strings"
...@@ -591,13 +590,17 @@ func readCmdFlags() error { ...@@ -591,13 +590,17 @@ func readCmdFlags() error {
Config.QueryTimeOut = *queryTimeOut Config.QueryTimeOut = *queryTimeOut
Config.LogLevel = *logLevel Config.LogLevel = *logLevel
if filepath.IsAbs(*logOutput) { if strings.HasPrefix(*logOutput, "/") {
Config.LogOutput = *logOutput Config.LogOutput = *logOutput
} else { } else {
if BaseDir == "" { if BaseDir == "" {
Config.LogOutput = *logOutput Config.LogOutput = *logOutput
} else { } else {
Config.LogOutput = filepath.Join(BaseDir, *logOutput) if runtime.GOOS == "windows" {
Config.LogOutput = *logOutput
} else {
Config.LogOutput = BaseDir + "/" + *logOutput
}
} }
} }
Config.ReportType = strings.ToLower(*reportType) Config.ReportType = strings.ToLower(*reportType)
...@@ -609,10 +612,11 @@ func readCmdFlags() error { ...@@ -609,10 +612,11 @@ func readCmdFlags() error {
Config.IgnoreRules = strings.Split(*ignoreRules, ",") Config.IgnoreRules = strings.Split(*ignoreRules, ",")
Config.RewriteRules = strings.Split(*rewriteRules, ",") Config.RewriteRules = strings.Split(*rewriteRules, ",")
*blackList = strings.TrimSpace(*blackList) *blackList = strings.TrimSpace(*blackList)
if filepath.IsAbs(*blackList) || *blackList == "" { if strings.HasPrefix(*blackList, "/") || *blackList == "" {
Config.BlackList = *blackList Config.BlackList = *blackList
} else { } else {
Config.BlackList = filepath.Join(BaseDir, *blackList) pwd, _ := os.Getwd()
Config.BlackList = pwd + "/" + *blackList
} }
Config.MaxJoinTableCount = *maxJoinTableCount Config.MaxJoinTableCount = *maxJoinTableCount
Config.MaxGroupByColsCount = *maxGroupByColsCount Config.MaxGroupByColsCount = *maxGroupByColsCount
...@@ -687,8 +691,8 @@ func ParseConfig(configFile string) error { ...@@ -687,8 +691,8 @@ func ParseConfig(configFile string) error {
if configFile == "" { if configFile == "" {
configs = []string{ configs = []string{
"/etc/soar.yaml", "/etc/soar.yaml",
filepath.Join(BaseDir, "etc", "soar.yaml"), BaseDir + "/etc/soar.yaml",
filepath.Join(BaseDir, "soar.yaml"), BaseDir + "/soar.yaml",
} }
} else { } else {
configs = []string{ configs = []string{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册