Plugins: Tidy up CLI code (#67813)

* more tidying

* move some things around

* more tidying

* fix linter
This commit is contained in:
Will Browne
2023-05-08 10:58:47 +02:00
committed by GitHub
parent 0fc9a47779
commit e0e2535c96
16 changed files with 307 additions and 298 deletions
@@ -16,17 +16,17 @@ func upgradeCommand(c utils.CommandLine) error {
pluginsDir := c.PluginDirectory()
pluginID := c.Args().First()
localPlugin, err := services.ReadPlugin(pluginsDir, pluginID)
localPlugin, err := services.GetLocalPlugin(pluginsDir, pluginID)
if err != nil {
return err
}
plugin, err := services.GetPlugin(pluginID, c.PluginRepoURL())
plugin, err := services.GetPluginInfoFromRepo(pluginID, c.PluginRepoURL())
if err != nil {
return err
}
if shouldUpgrade(localPlugin.Info.Version, &plugin) {
if shouldUpgrade(localPlugin, plugin) {
if err = uninstallPlugin(ctx, pluginID, c); err != nil {
return fmt.Errorf("failed to remove plugin '%s': %w", pluginID, err)
}