GetCLIPlugin returns the specified Docker CLI plugin by name, or an error if not found or if the plugin has an error.
(name string)
| 242 | |
| 243 | // GetCLIPlugin returns the specified Docker CLI plugin by name, or an error if not found or if the plugin has an error. |
| 244 | func GetCLIPlugin(name string) (manager.Plugin, error) { |
| 245 | plugins, err := GetCLIPlugins() |
| 246 | if err != nil { |
| 247 | return manager.Plugin{}, err |
| 248 | } |
| 249 | for _, p := range plugins { |
| 250 | if p.Name == name { |
| 251 | if p.Err != nil { |
| 252 | return p, fmt.Errorf("plugin %q has error: %v", name, p.Err) |
| 253 | } |
| 254 | return p, nil |
| 255 | } |
| 256 | } |
| 257 | return manager.Plugin{}, fmt.Errorf("docker CLI plugin %q not found", name) |
| 258 | } |
no test coverage detected