(out io.Writer)
| 61 | } |
| 62 | |
| 63 | func (o *pluginUninstallOptions) run(out io.Writer) error { |
| 64 | slog.Debug("loading installer plugins", "dir", settings.PluginsDirectory) |
| 65 | plugins, err := plugin.LoadAllDir(settings.PluginsDirectory, plugin.LogIgnorePluginLoadErrorFilterFunc) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | var errorPlugins []error |
| 70 | for _, name := range o.names { |
| 71 | if found := findPlugin(plugins, name); found != nil { |
| 72 | if err := uninstallPlugin(found); err != nil { |
| 73 | errorPlugins = append(errorPlugins, fmt.Errorf("failed to uninstall plugin %s, got error (%v)", name, err)) |
| 74 | } else { |
| 75 | fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) |
| 76 | } |
| 77 | } else { |
| 78 | errorPlugins = append(errorPlugins, fmt.Errorf("plugin: %s not found", name)) |
| 79 | } |
| 80 | } |
| 81 | if len(errorPlugins) > 0 { |
| 82 | return errors.Join(errorPlugins...) |
| 83 | } |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | func uninstallPlugin(p plugin.Plugin) error { |
| 88 | if err := os.RemoveAll(p.Dir()); err != nil { |
no test coverage detected