mirror of
https://github.com/grafana/grafana.git
synced 2025-09-26 04:34:28 +08:00

* installer -> repo * add semver format checking * add plugin callbacks in test * remove newline * post install only scans new directories * remove unused stuff * everything in own package * add missing cli params * make grafana version part of the API * resolve conflicts * tidy up logger * fix cli and tidy log statements * rename log package * update struct name * fix linter issue * fs -> filestore * reorder imports * alias import * fix test * fix test * inline var * revert jsonc file * make repo dep of manager * actually inject the thing * accept all args for compatability checks * accept compat from store * pass os + arch vals * don't inject fs * tidy up * tidy up * merge with main and tidy fs storage * fix test * fix packages * fix comment + field name * update fs naming * fixed wire * remove unused func * fix mocks * fix storage test * renaming * fix log line * fix test * re-order field * tidying * add test for update with same version * fix wire for CLI * remove use of ioutil * don't pass field * small tidy * ignore code scanning warn * fix testdata link * update lgtm code
39 lines
958 B
Go
39 lines
958 B
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/fatih/color"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
|
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
|
)
|
|
|
|
func (cmd Command) upgradeCommand(c utils.CommandLine) error {
|
|
pluginsDir := c.PluginDirectory()
|
|
pluginName := c.Args().First()
|
|
|
|
localPlugin, err := services.ReadPlugin(pluginsDir, pluginName)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
plugin, err2 := cmd.Client.GetPlugin(pluginName, c.PluginRepoURL())
|
|
if err2 != nil {
|
|
return err2
|
|
}
|
|
|
|
if shouldUpgrade(localPlugin.Info.Version, &plugin) {
|
|
if err := services.RemoveInstalledPlugin(pluginsDir, pluginName); err != nil {
|
|
return fmt.Errorf("failed to remove plugin '%s': %w", pluginName, err)
|
|
}
|
|
|
|
return installPlugin(context.Background(), pluginName, "", c)
|
|
}
|
|
|
|
logger.Infof("%s %s is up to date \n", color.GreenString("✔"), pluginName)
|
|
return nil
|
|
}
|