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