mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 07:02:22 +08:00
Add check for update/uninstall of plugins (#91889)
This commit is contained in:

committed by
GitHub

parent
134b9f731f
commit
55381a3e77
@ -458,6 +458,12 @@ func (hs *HTTPServer) InstallPlugin(c *contextmodel.ReqContext) response.Respons
|
||||
|
||||
hs.log.Info("Plugin install/update requested", "pluginId", pluginID, "user", c.Login)
|
||||
|
||||
for _, preinstalled := range hs.Cfg.InstallPlugins {
|
||||
if preinstalled.ID == pluginID && preinstalled.Version != "" {
|
||||
return response.Error(http.StatusConflict, "Cannot update a pinned pre-installed plugin", nil)
|
||||
}
|
||||
}
|
||||
|
||||
compatOpts := plugins.NewCompatOpts(hs.Cfg.BuildVersion, runtime.GOOS, runtime.GOARCH)
|
||||
err := hs.pluginInstaller.Add(c.Req.Context(), pluginID, dto.Version, compatOpts)
|
||||
if err != nil {
|
||||
@ -496,6 +502,12 @@ func (hs *HTTPServer) UninstallPlugin(c *contextmodel.ReqContext) response.Respo
|
||||
return response.Error(http.StatusNotFound, "Plugin not installed", nil)
|
||||
}
|
||||
|
||||
for _, preinstalled := range hs.Cfg.InstallPlugins {
|
||||
if preinstalled.ID == pluginID {
|
||||
return response.Error(http.StatusConflict, "Cannot uninstall a pre-installed plugin", nil)
|
||||
}
|
||||
}
|
||||
|
||||
err := hs.pluginInstaller.Remove(c.Req.Context(), pluginID, plugin.Info.Version)
|
||||
if err != nil {
|
||||
if errors.Is(err, plugins.ErrPluginNotInstalled) {
|
||||
|
Reference in New Issue
Block a user