-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
upgrade_command.go
32 lines (24 loc) · 719 Bytes
/
upgrade_command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package commands
import (
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
func upgradeCommand(c CommandLine) error {
pluginsDir := c.PluginDirectory()
pluginName := c.Args().First()
localPlugin, err := s.ReadPlugin(pluginsDir, pluginName)
if err != nil {
return err
}
v, err2 := s.GetPlugin(localPlugin.Id, c.RepoDirectory())
if err2 != nil {
return err2
}
if ShouldUpgrade(localPlugin.Info.Version, v) {
s.RemoveInstalledPlugin(pluginsDir, pluginName)
return InstallPlugin(localPlugin.Id, "", c)
}
logger.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
return nil
}