Files
grafana/pkg/cmd/grafana-cli/commands/listversions_command.go
T
Will Browne fd28c8490f Plugins: Tidy up CLI code (#67723)
* remove dead code and use pkg/plugins for uninstall process

* fix linter

* remove unnecessary cruft
2023-05-04 10:52:09 +02:00

38 lines
739 B
Go

package commands
import (
"errors"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
)
func validateVersionInput(c utils.CommandLine) error {
arg := c.Args().First()
if arg == "" {
return errors.New("please specify plugin to list versions for")
}
return nil
}
func listVersionsCommand(c utils.CommandLine) error {
if err := validateVersionInput(c); err != nil {
return err
}
pluginToList := c.Args().First()
plugin, err := services.GetPlugin(pluginToList, c.String("repo"))
if err != nil {
return err
}
for _, i := range plugin.Versions {
logger.Infof("%v\n", i.Version)
}
return nil
}