Skip to content

Commit c10be0b

Browse files
committed
return error if no groups are found
Signed-off-by: Jean Mertz <[email protected]>
1 parent bb2571a commit c10be0b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmd/saw.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,23 @@ func runMultiGroup(pattern string, fn func(string)) error {
4242
}
4343

4444
b := blade.NewBlade(&config.Configuration{}, &awsConfig, nil)
45+
groups := b.GetLogGroups()
46+
if len(groups) == 0 {
47+
return fmt.Errorf("no groups found matching pattern: %s", pattern)
48+
}
4549

4650
var wg sync.WaitGroup
47-
for _, group := range b.GetLogGroups() {
48-
name := group.LogGroupName
49-
if name == nil || !re.MatchString(*name) {
51+
for _, g := range groups {
52+
group := g.LogGroupName
53+
if group == nil || !re.MatchString(*group) {
5054
continue
5155
}
5256

5357
wg.Add(1)
5458
go func(group string) {
5559
defer wg.Done()
5660
fn(group)
57-
}(*name)
61+
}(*group)
5862
}
5963

6064
wg.Wait()

0 commit comments

Comments
 (0)