func (m *ruleManager) AddRulesFromConfig(config config.Config) error { for _, ruleFile := range config.Global.RuleFile { newRules, err := rules.LoadRulesFromFile(ruleFile) if err != nil { return fmt.Errorf("%s: %s", ruleFile, err) } m.Lock() m.rules = append(m.rules, newRules...) m.Unlock() } return nil }
func main() { flag.Parse() if *ruleFile == "" { glog.Fatal("Must provide a rule file path") } rules, err := rules.LoadRulesFromFile(*ruleFile) if err != nil { glog.Fatalf("Error loading rule file %s: %s", *ruleFile, err) } fmt.Printf("Successfully loaded %d rules:\n\n", len(rules)) for _, rule := range rules { fmt.Println(rule) } }