mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Add logs to for plugin management actions (#90587)
* Plugins: Add logs to for plugin management actions --------- Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>
This commit is contained in:
parent
08c611c68b
commit
5c966fd400
@ -456,6 +456,8 @@ func (hs *HTTPServer) InstallPlugin(c *contextmodel.ReqContext) response.Respons
|
||||
}
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
hs.log.Info("Plugin install/update requested", "pluginId", pluginID, "user", c.Login)
|
||||
|
||||
compatOpts := plugins.NewCompatOpts(hs.Cfg.BuildVersion, runtime.GOOS, runtime.GOARCH)
|
||||
err := hs.pluginInstaller.Add(c.Req.Context(), pluginID, dto.Version, compatOpts)
|
||||
if err != nil {
|
||||
@ -486,6 +488,9 @@ func (hs *HTTPServer) InstallPlugin(c *contextmodel.ReqContext) response.Respons
|
||||
|
||||
func (hs *HTTPServer) UninstallPlugin(c *contextmodel.ReqContext) response.Response {
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
hs.log.Info("Plugin uninstall requested", "pluginId", pluginID, "user", c.Login)
|
||||
|
||||
plugin, exists := hs.pluginStore.Plugin(c.Req.Context(), pluginID)
|
||||
if !exists {
|
||||
return response.Error(http.StatusNotFound, "Plugin not installed", nil)
|
||||
|
@ -109,6 +109,8 @@ func Test_PluginsInstallAndUninstall(t *testing.T) {
|
||||
hs.authnService = &authntest.FakeService{
|
||||
ExpectedIdentity: expectedIdentity,
|
||||
}
|
||||
|
||||
hs.log = log.NewNopLogger()
|
||||
})
|
||||
|
||||
t.Run(testName("Install", tc), func(t *testing.T) {
|
||||
|
@ -107,6 +107,8 @@ func (m *PluginInstaller) install(ctx context.Context, pluginID, version string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m.log.Info("Updating plugin", "pluginId", pluginID, "from", plugin.Info.Version, "to", pluginArchiveInfo.Version)
|
||||
|
||||
// if existing plugin version is the same as the target update version
|
||||
if pluginArchiveInfo.Version == plugin.Info.Version {
|
||||
return nil, plugins.DuplicateError{
|
||||
@ -141,6 +143,7 @@ func (m *PluginInstaller) install(ctx context.Context, pluginID, version string,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.log.Info("Installing plugin", "pluginId", pluginID, "version", version)
|
||||
}
|
||||
|
||||
extractedArchive, err := m.pluginStorage.Extract(ctx, pluginID, m.pluginStorageDirFunc, pluginArchive.File)
|
||||
|
Loading…
Reference in New Issue
Block a user