Plugins: Plugin Store API returns DTO model (#41340)
* toying around * fix refs * remove unused fields * go further * add context * ensure streaming handler is set
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -113,7 +114,7 @@ func (cr *configReaderImpl) validatePluginsConfig(apps []*pluginsAsConfig) error
|
||||
}
|
||||
|
||||
for _, app := range apps[i].Apps {
|
||||
if p := cr.pluginStore.Plugin(app.PluginID); p == nil {
|
||||
if _, exists := cr.pluginStore.Plugin(context.TODO(), app.PluginID); !exists {
|
||||
return fmt.Errorf("plugin not installed: %q", app.PluginID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -47,7 +48,7 @@ func TestConfigReader(t *testing.T) {
|
||||
|
||||
t.Run("Can read correct properties", func(t *testing.T) {
|
||||
pm := fakePluginStore{
|
||||
apps: map[string]*plugins.Plugin{
|
||||
apps: map[string]plugins.PluginDTO{
|
||||
"test-plugin": {},
|
||||
"test-plugin-2": {},
|
||||
},
|
||||
@@ -90,9 +91,11 @@ func TestConfigReader(t *testing.T) {
|
||||
type fakePluginStore struct {
|
||||
plugins.Store
|
||||
|
||||
apps map[string]*plugins.Plugin
|
||||
apps map[string]plugins.PluginDTO
|
||||
}
|
||||
|
||||
func (pr fakePluginStore) Plugin(pluginID string) *plugins.Plugin {
|
||||
return pr.apps[pluginID]
|
||||
func (pr fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
||||
p, exists := pr.apps[pluginID]
|
||||
|
||||
return p, exists
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user