From ad278622e460813b49561eaf67401288f3e10d4c Mon Sep 17 00:00:00 2001 From: Varsha Varadarajan Date: Fri, 28 Jun 2019 13:44:46 -0400 Subject: [PATCH] Show an error if group not found. --- checks/check_filter.go | 3 ++- checks/registry.go | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/checks/check_filter.go b/checks/check_filter.go index 49e19dd..72c5744 100644 --- a/checks/check_filter.go +++ b/checks/check_filter.go @@ -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 { diff --git a/checks/registry.go b/checks/registry.go index bbbe732..09850d5 100644 --- a/checks/registry.go +++ b/checks/registry.go @@ -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,