mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 13:39:19 -06:00
36 lines
879 B
Go
36 lines
879 B
Go
package commands
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
|
|
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
|
|
services "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
|
)
|
|
|
|
var getPluginss func(path string) []m.InstalledPlugin = services.GetLocalPlugins
|
|
var removePlugin func(pluginPath, id string) error = services.RemoveInstalledPlugin
|
|
|
|
func removeCommand(c CommandLine) error {
|
|
pluginPath := c.GlobalString("path")
|
|
localPlugins := getPluginss(pluginPath)
|
|
|
|
log.Info("remove!\n")
|
|
|
|
plugin := c.Args().First()
|
|
log.Info("plugin: " + plugin + "\n")
|
|
if plugin == "" {
|
|
return errors.New("Missing plugin parameter")
|
|
}
|
|
|
|
log.Infof("plugins : \n%v\n", localPlugins)
|
|
|
|
for _, p := range localPlugins {
|
|
if p.Id == c.Args().First() {
|
|
log.Infof("removing plugin %s", p.Id)
|
|
removePlugin(pluginPath, p.Id)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|