ImageNames offers completion for images present within the local store
(dockerCLI APIClientProvider, limit int)
| 22 | |
| 23 | // ImageNames offers completion for images present within the local store |
| 24 | func ImageNames(dockerCLI APIClientProvider, limit int) cobra.CompletionFunc { |
| 25 | return Unique(func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 26 | if limit > 0 && len(args) >= limit { |
| 27 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 28 | } |
| 29 | res, err := dockerCLI.Client().ImageList(cmd.Context(), client.ImageListOptions{}) |
| 30 | if err != nil { |
| 31 | return nil, cobra.ShellCompDirectiveError |
| 32 | } |
| 33 | var names []string |
| 34 | for _, img := range res.Items { |
| 35 | names = append(names, img.RepoTags...) |
| 36 | } |
| 37 | return names, cobra.ShellCompDirectiveNoFileComp |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | // ImageNamesWithBase offers completion for images present within the local store, |
| 42 | // including both full image names with tags and base image names (repository names only) |
searching dependent graphs…