in controller/ad/ad.go [415:449]
func (c controller) processDetectorByAction(ctx context.Context, pattern string, action string, f func(c context.Context, s string) error, display bool, warning bool) error {
matchedDetectors, err := c.getDetectors(ctx, action, pattern, warning)
if err != nil {
return err
}
if matchedDetectors == nil {
return nil
}
var bar *pb.ProgressBar
if display {
bar = createProgressBar(len(matchedDetectors))
}
var failedDetectors []string
for _, detector := range matchedDetectors {
err := f(ctx, detector.ID)
if err != nil {
failedDetectors = append(failedDetectors, fmt.Sprintf("%s \t Reason: %s", detector.Name, err))
continue
}
if bar != nil {
bar.Increment()
}
}
if bar != nil {
bar.Finish()
}
if len(failedDetectors) < 1 {
return nil
}
fmt.Printf("\nfailed to %s %d following detector(s)\n", action, len(failedDetectors))
for _, detector := range failedDetectors {
fmt.Println(detector)
}
return nil
}