IndexNames returns a function to list the index names from the given search client.
( clientF func() (*search.APIClient, error), )
| 10 | |
| 11 | // IndexNames returns a function to list the index names from the given search client. |
| 12 | func IndexNames( |
| 13 | clientF func() (*search.APIClient, error), |
| 14 | ) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 15 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 16 | client, err := clientF() |
| 17 | if err != nil { |
| 18 | return nil, cobra.ShellCompDirectiveError |
| 19 | } |
| 20 | res, err := client.ListIndices(client.NewApiListIndicesRequest()) |
| 21 | if err != nil { |
| 22 | return nil, cobra.ShellCompDirectiveError |
| 23 | } |
| 24 | |
| 25 | names := make([]string, 0, len(res.Items)) |
| 26 | for _, index := range res.Items { |
| 27 | names = append(names, index.Name) |
| 28 | } |
| 29 | return names, cobra.ShellCompDirectiveNoFileComp |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // CrawlerIDs returns a function to list the crawler IDs from the given crawler client. |
| 34 | func CrawlerIDs( |
no outgoing calls
no test coverage detected