in controller/ad/ad.go [502:529]
func (c controller) GetDetectorsByName(ctx context.Context, pattern string, display bool) ([]*entity.DetectorOutput, error) {
matchedDetectors, err := c.getDetectors(ctx, "fetch", pattern, false)
if err != nil {
return nil, err
}
if matchedDetectors == nil {
return nil, nil
}
var bar *pb.ProgressBar
if display {
bar = createProgressBar(len(matchedDetectors))
}
var output []*entity.DetectorOutput
for _, detector := range matchedDetectors {
data, err := c.GetDetector(ctx, detector.ID)
if err != nil {
return nil, err
}
output = append(output, data)
if bar != nil {
bar.Increment()
}
}
if bar != nil {
bar.Finish()
}
return output, nil
}