conf: support relative path in "rules-dir" config

This commit is contained in:
nadoo 2017-08-25 20:32:51 +08:00
parent 1a941cd095
commit 419fa05171

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"path"
"github.com/nadoo/conflag" "github.com/nadoo/conflag"
) )
@ -66,8 +67,9 @@ func confInit() {
conf.rules = append(conf.rules, rule) conf.rules = append(conf.rules, rule)
} }
// TODO: allow to use relative dir to the config file conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule") ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule")
for _, ruleFile := range ruleFolderFiles { for _, ruleFile := range ruleFolderFiles {
rule, err := NewRuleConfFromFile(ruleFile) rule, err := NewRuleConfFromFile(ruleFile)
if err != nil { if err != nil {