2016-02-15 14:09:34 +01:00
|
|
|
package commands
|
|
|
|
|
|
|
|
|
|
import (
|
2016-05-12 04:43:31 -04:00
|
|
|
"github.com/fatih/color"
|
2016-06-03 12:19:04 +02:00
|
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
|
2016-02-16 08:49:27 +01:00
|
|
|
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
2016-02-15 14:09:34 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func upgradeCommand(c CommandLine) error {
|
2016-06-24 20:14:58 +02:00
|
|
|
pluginsDir := c.PluginDirectory()
|
2016-02-16 08:49:27 +01:00
|
|
|
pluginName := c.Args().First()
|
|
|
|
|
|
2016-03-28 21:42:26 +02:00
|
|
|
localPlugin, err := s.ReadPlugin(pluginsDir, pluginName)
|
2016-02-16 08:49:27 +01:00
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 17:19:51 -04:00
|
|
|
v, err2 := s.GetPlugin(pluginName, c.RepoDirectory())
|
2016-02-16 08:49:27 +01:00
|
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
|
return err2
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 04:43:31 -04:00
|
|
|
if ShouldUpgrade(localPlugin.Info.Version, v) {
|
|
|
|
|
s.RemoveInstalledPlugin(pluginsDir, pluginName)
|
2018-09-13 17:19:51 -04:00
|
|
|
return InstallPlugin(pluginName, "", c)
|
2016-02-16 08:49:27 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 17:19:51 -04:00
|
|
|
logger.Infof("%s %s is up to date \n", color.GreenString("✔"), pluginName)
|
2016-02-16 08:49:27 +01:00
|
|
|
return nil
|
2016-02-15 14:09:34 +01:00
|
|
|
}
|