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
+3 -5
View File
@@ -6,13 +6,10 @@ import (
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
)
var ls_getPlugins func(path string) []models.InstalledPlugin = services.GetLocalPlugins
var (
errMissingPathFlag = errors.New("missing path flag")
errNotDirectory = errors.New("plugin path is not a directory")
@@ -41,7 +38,7 @@ func lsCommand(c utils.CommandLine) error {
return err
}
plugins := ls_getPlugins(pluginDir)
plugins := services.GetLocalPlugins(pluginDir)
if len(plugins) > 0 {
logger.Info("installed plugins:\n")
@@ -50,7 +47,8 @@ func lsCommand(c utils.CommandLine) error {
}
for _, plugin := range plugins {
logger.Infof("%s %s %s\n", plugin.ID, color.YellowString("@"), plugin.Info.Version)
logger.Infof("%s %s %s\n", plugin.Primary.JSONData.ID,
color.YellowString("@"), plugin.Primary.JSONData.Info.Version)
}
return nil