Show an error if group not found.

varsha/versions
Varsha Varadarajan 2019-06-28 13:44:46 -04:00
parent 4fdebb22d3
commit ad278622e4
2 changed files with 7 additions and 4 deletions

View File

@ -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 {

View File

@ -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,