2016-02-15 21:09:34 +08:00
|
|
|
package commands
|
|
|
|
|
|
|
|
|
|
import (
|
2016-05-12 16:43:31 +08:00
|
|
|
"github.com/fatih/color"
|
|
|
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
|
2016-02-16 15:49:27 +08:00
|
|
|
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
2016-02-15 21:09:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func upgradeCommand(c CommandLine) error {
|
2016-03-29 03:42:26 +08:00
|
|
|
pluginsDir := c.GlobalString("pluginsDir")
|
2016-02-16 15:49:27 +08:00
|
|
|
pluginName := c.Args().First()
|
|
|
|
|
|
2016-03-29 03:42:26 +08:00
|
|
|
localPlugin, err := s.ReadPlugin(pluginsDir, pluginName)
|
2016-02-16 15:49:27 +08:00
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 16:43:31 +08:00
|
|
|
v, err2 := s.GetPlugin(localPlugin.Id, c.GlobalString("repo"))
|
2016-02-16 15:49:27 +08:00
|
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
|
return err2
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 16:43:31 +08:00
|
|
|
if ShouldUpgrade(localPlugin.Info.Version, v) {
|
|
|
|
|
s.RemoveInstalledPlugin(pluginsDir, pluginName)
|
|
|
|
|
return InstallPlugin(localPlugin.Id, "", c)
|
2016-02-16 15:49:27 +08:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 16:43:31 +08:00
|
|
|
log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
|
2016-02-16 15:49:27 +08:00
|
|
|
return nil
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|