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.
This commit is contained in:
parent
a9400b7cd3
commit
bd6288dae0
12
app/conf.go
12
app/conf.go
@ -55,11 +55,17 @@ func (c *Conf) setup() {
|
|||||||
for patternName, pattern := range c.Patterns {
|
for patternName, pattern := range c.Patterns {
|
||||||
c.Patterns[patternName] = fmt.Sprintf("(?P<%s>%s)", patternName, pattern)
|
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 {
|
for streamName := range c.Streams {
|
||||||
|
|
||||||
stream := c.Streams[streamName]
|
stream := c.Streams[streamName]
|
||||||
stream.name = 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 {
|
for filterName := range stream.Filters {
|
||||||
|
|
||||||
filter := stream.Filters[filterName]
|
filter := stream.Filters[filterName]
|
||||||
@ -74,6 +80,9 @@ func (c *Conf) setup() {
|
|||||||
}
|
}
|
||||||
filter.retryDuration = retryDuration
|
filter.retryDuration = retryDuration
|
||||||
|
|
||||||
|
if len(filter.Regex) == 0 {
|
||||||
|
log.Fatalln("Bad configuration: no regexes configured in '%s.%s'!", stream.name, filter.name)
|
||||||
|
}
|
||||||
// Compute Regexes
|
// Compute Regexes
|
||||||
// Look for Patterns inside Regexes
|
// Look for Patterns inside Regexes
|
||||||
for _, regex := range filter.Regex {
|
for _, regex := range filter.Regex {
|
||||||
@ -99,6 +108,9 @@ func (c *Conf) setup() {
|
|||||||
filter.compiledRegex = append(filter.compiledRegex, *regexp.MustCompile(regex))
|
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 {
|
for actionName := range filter.Actions {
|
||||||
|
|
||||||
action := filter.Actions[actionName]
|
action := filter.Actions[actionName]
|
||||||
|
Loading…
Reference in New Issue
Block a user