in controller/ad/ad.go [383:413]
func (c controller) getDetectors(ctx context.Context, method string, pattern string, warning bool) ([]entity.Detector, error) {
if len(pattern) < 1 {
return nil, fmt.Errorf("name cannot be empty")
}
//Search Detector By Name to get ID
matchedDetectors, err := c.SearchDetectorByName(ctx, pattern)
if err != nil {
return nil, err
}
if len(matchedDetectors) < 1 {
fmt.Printf("no detectors matched by name %s\n", pattern)
return nil, nil
}
if !warning {
return matchedDetectors, nil
}
fmt.Printf("%d detectors matched by name %s\n", len(matchedDetectors), pattern)
for _, detector := range matchedDetectors {
fmt.Println(detector.Name)
}
proceed := c.askForConfirmation(
mapper.StringToStringPtr(
fmt.Sprintf("opensearch-cli will %s above matched detector(s). Do you want to proceed? Y/N ", method),
),
)
if !proceed {
return nil, nil
}
return matchedDetectors, nil
}