Show an error if group not found.
parent
4fdebb22d3
commit
ad278622e4
|
@ -52,7 +52,8 @@ func (c CheckFilter) filterGroups() ([]Check, error) {
|
|||
}
|
||||
|
||||
if len(c.IncludeGroups) > 0 {
|
||||
return GetGroups(c.IncludeGroups), nil
|
||||
groups, err := GetGroups(c.IncludeGroups)
|
||||
return groups, err
|
||||
} else if len(c.ExcludeGroups) > 0 {
|
||||
return c.getChecksNotInGroups(c.ExcludeGroups), nil
|
||||
} else {
|
||||
|
|
|
@ -86,18 +86,20 @@ func GetGroup(name string) []Check {
|
|||
}
|
||||
|
||||
// GetGroups returns checks that belong to any of the specified group.
|
||||
func GetGroups(groups []string) []Check {
|
||||
func GetGroups(groups []string) ([]Check, error) {
|
||||
registry.mu.RLock()
|
||||
defer registry.mu.RUnlock()
|
||||
var ret []Check
|
||||
for _, group := range groups {
|
||||
if checks, ok := registry.groups[group]; ok {
|
||||
ret = append(ret, checks...)
|
||||
} else {
|
||||
return nil, fmt.Errorf("Group %s not found", group)
|
||||
}
|
||||
// else do we log an error?
|
||||
|
||||
}
|
||||
|
||||
return ret
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Get retrieves the specified check from the registry,
|
||||
|
|
Loading…
Reference in New Issue