Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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)
	}
}