From bd6288dae0e89e65ac594f8f334bcf59774325e3 Mon Sep 17 00:00:00 2001 From: ppom <> Date: Wed, 12 Apr 2023 09:53:44 +0200 Subject: [PATCH] Do not allow for empty conf, stream, filter, regex or action. This means the minimal valid configuration contains one stream, with one filter, with one regex and one action. --- app/conf.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/conf.go b/app/conf.go index 90c60f8..119e0fa 100644 --- a/app/conf.go +++ b/app/conf.go @@ -55,11 +55,17 @@ func (c *Conf) setup() { for patternName, pattern := range c.Patterns { c.Patterns[patternName] = fmt.Sprintf("(?P<%s>%s)", patternName, pattern) } + if len(c.Streams) == 0 { + log.Fatalln("Bad configuration: no streams configured!") + } for streamName := range c.Streams { stream := c.Streams[streamName] stream.name = streamName + if len(stream.Filters) == 0 { + log.Fatalln("Bad configuration: no filters configured in '%s'!", stream.name) + } for filterName := range stream.Filters { filter := stream.Filters[filterName] @@ -74,6 +80,9 @@ func (c *Conf) setup() { } filter.retryDuration = retryDuration + if len(filter.Regex) == 0 { + log.Fatalln("Bad configuration: no regexes configured in '%s.%s'!", stream.name, filter.name) + } // Compute Regexes // Look for Patterns inside Regexes for _, regex := range filter.Regex { @@ -99,6 +108,9 @@ func (c *Conf) setup() { filter.compiledRegex = append(filter.compiledRegex, *regexp.MustCompile(regex)) } + if len(filter.Actions) == 0 { + log.Fatalln("Bad configuration: no actions configured in '%s.%s'!", stream.name, filter.name) + } for actionName := range filter.Actions { action := filter.Actions[actionName]