completeLogDriver implements shell completion for the `--log-driver` option of `run` and `create`. The log drivers are collected from a call to the Info endpoint with a fallback to a hard-coded list of the build-in log drivers.
(dockerCLI completion.APIClientProvider)
| 215 | // The log drivers are collected from a call to the Info endpoint with a fallback to a hard-coded list |
| 216 | // of the build-in log drivers. |
| 217 | func completeLogDriver(dockerCLI completion.APIClientProvider) cobra.CompletionFunc { |
| 218 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 219 | res, err := dockerCLI.Client().Info(cmd.Context(), client.InfoOptions{}) |
| 220 | if err != nil { |
| 221 | return builtInLogDrivers(), cobra.ShellCompDirectiveNoFileComp |
| 222 | } |
| 223 | drivers := res.Info.Plugins.Log |
| 224 | return drivers, cobra.ShellCompDirectiveNoFileComp |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // completeLogOpt implements shell completion for the `--log-opt` option of `run` and `create`. |
| 229 | // If the user supplied a log-driver, only options for that driver are returned. |
no test coverage detected
searching dependent graphs…