Plugins: Invalidate plugin context app settings cache post update (#63279)

invalid plugin settings
scenes-custom-transformer
Will Browne 2 years ago committed by GitHub
parent 19d1a46f30
commit 200d2ad249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      pkg/api/plugins.go
  2. 10
      pkg/plugins/plugincontext/plugincontext.go

@ -263,6 +263,8 @@ func (hs *HTTPServer) UpdatePluginSetting(c *contextmodel.ReqContext) response.R
return response.Error(500, "Failed to update plugin setting", err) return response.Error(500, "Failed to update plugin setting", err)
} }
hs.PluginContextProvider.InvalidateSettingsCache(c.Req.Context(), pluginID)
return response.Success("Plugin settings updated") return response.Success("Plugin settings updated")
} }

@ -106,7 +106,7 @@ func (p *Provider) pluginContext(ctx context.Context, pluginID string, user *use
} }
func (p *Provider) getCachedPluginSettings(ctx context.Context, pluginID string, user *user.SignedInUser) (*pluginsettings.DTO, error) { func (p *Provider) getCachedPluginSettings(ctx context.Context, pluginID string, user *user.SignedInUser) (*pluginsettings.DTO, error) {
cacheKey := pluginSettingsCachePrefix + pluginID cacheKey := getCacheKey(pluginID)
if cached, found := p.cacheService.Get(cacheKey); found { if cached, found := p.cacheService.Get(cacheKey); found {
ps := cached.(*pluginsettings.DTO) ps := cached.(*pluginsettings.DTO)
@ -127,8 +127,16 @@ func (p *Provider) getCachedPluginSettings(ctx context.Context, pluginID string,
return ps, nil return ps, nil
} }
func (p *Provider) InvalidateSettingsCache(_ context.Context, pluginID string) {
p.cacheService.Delete(getCacheKey(pluginID))
}
func (p *Provider) decryptSecureJsonDataFn(ctx context.Context) func(ds *datasources.DataSource) (map[string]string, error) { func (p *Provider) decryptSecureJsonDataFn(ctx context.Context) func(ds *datasources.DataSource) (map[string]string, error) {
return func(ds *datasources.DataSource) (map[string]string, error) { return func(ds *datasources.DataSource) (map[string]string, error) {
return p.dataSourceService.DecryptedValues(ctx, ds) return p.dataSourceService.DecryptedValues(ctx, ds)
} }
} }
func getCacheKey(pluginID string) string {
return pluginSettingsCachePrefix + pluginID
}

Loading…
Cancel
Save