mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added grafana-cli command. Added public documentation for specifying plugin version when installing. (#5665)
This commit is contained in:
committed by
Torkel Ödegaard
parent
e8e8463828
commit
39be7cf7d7
@@ -27,12 +27,16 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
|
|||||||
var pluginCommands = []cli.Command{
|
var pluginCommands = []cli.Command{
|
||||||
{
|
{
|
||||||
Name: "install",
|
Name: "install",
|
||||||
Usage: "install <plugin id>",
|
Usage: "install <plugin id> <plugin version (optional)>",
|
||||||
Action: runCommand(installCommand),
|
Action: runCommand(installCommand),
|
||||||
}, {
|
}, {
|
||||||
Name: "list-remote",
|
Name: "list-remote",
|
||||||
Usage: "list remote available plugins",
|
Usage: "list remote available plugins",
|
||||||
Action: runCommand(listremoteCommand),
|
Action: runCommand(listremoteCommand),
|
||||||
|
}, {
|
||||||
|
Name: "list-versions",
|
||||||
|
Usage: "list-versions <plugin id>",
|
||||||
|
Action: runCommand(listversionsCommand),
|
||||||
}, {
|
}, {
|
||||||
Name: "update",
|
Name: "update",
|
||||||
Usage: "update <plugin id>",
|
Usage: "update <plugin id>",
|
||||||
|
|||||||
36
pkg/cmd/grafana-cli/commands/listversions_command.go
Normal file
36
pkg/cmd/grafana-cli/commands/listversions_command.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
|
||||||
|
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
func validateVersionInput(c CommandLine) error {
|
||||||
|
arg := c.Args().First()
|
||||||
|
if arg == "" {
|
||||||
|
return errors.New("please specify plugin to list versions for")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func listversionsCommand(c CommandLine) error {
|
||||||
|
if err := validateVersionInput(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginToList := c.Args().First()
|
||||||
|
|
||||||
|
plugin, err := s.GetPlugin(pluginToList, c.GlobalString("repo"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, i := range plugin.Versions {
|
||||||
|
logger.Infof("%v\n", i.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user