[v9.0.x] Plugins: Register management endpoints only when external managed is also false (#51817)
* Plugins: Register management endpoints only when external managed is also false (#51802)
* Only define plugin install endpoints when catalog enabled
* add external check
(cherry picked from commit 40dff288cd)
* fix test
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
This commit is contained in:
co-authored by
Will Browne
Will Browne
parent
65f31f978c
commit
11c15f3bfa
+21
-6
@@ -7,20 +7,18 @@ import (
|
||||
)
|
||||
|
||||
type fakePluginStore struct {
|
||||
plugins.Store
|
||||
|
||||
plugins map[string]plugins.PluginDTO
|
||||
}
|
||||
|
||||
func (pr fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
||||
p, exists := pr.plugins[pluginID]
|
||||
func (ps fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
||||
p, exists := ps.plugins[pluginID]
|
||||
|
||||
return p, exists
|
||||
}
|
||||
|
||||
func (pr fakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
|
||||
func (ps fakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
|
||||
var result []plugins.PluginDTO
|
||||
for _, v := range pr.plugins {
|
||||
for _, v := range ps.plugins {
|
||||
for _, t := range pluginTypes {
|
||||
if v.Type == t {
|
||||
result = append(result, v)
|
||||
@@ -31,6 +29,23 @@ func (pr fakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type
|
||||
return result
|
||||
}
|
||||
|
||||
func (ps fakePluginStore) Add(_ context.Context, pluginID, version string) error {
|
||||
ps.plugins[pluginID] = plugins.PluginDTO{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: pluginID,
|
||||
Info: plugins.Info{
|
||||
Version: version,
|
||||
},
|
||||
},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps fakePluginStore) Remove(_ context.Context, pluginID string) error {
|
||||
delete(ps.plugins, pluginID)
|
||||
return nil
|
||||
}
|
||||
|
||||
type fakeRendererManager struct {
|
||||
plugins.RendererManager
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user