Chore: Add skeleton for background plugin installer (#91743)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package plugininstaller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
features featuremgmt.FeatureToggles
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
func ProvideService(cfg *setting.Cfg, features featuremgmt.FeatureToggles) *Service {
|
||||
s := &Service{
|
||||
features: features,
|
||||
log: log.New("plugin.installer"),
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// IsDisabled disables background installation of plugins.
|
||||
func (s *Service) IsDisabled() bool {
|
||||
return !s.features.IsEnabled(context.Background(), featuremgmt.FlagBackgroundPluginInstaller)
|
||||
}
|
||||
|
||||
func (s *Service) Run(ctx context.Context) error {
|
||||
s.log.Debug("PluginInstaller.Run not implemented")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package plugininstaller
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
||||
// Test if the service is disabled
|
||||
func TestService_IsDisabled(t *testing.T) {
|
||||
// Create a new service
|
||||
s := &Service{
|
||||
features: featuremgmt.WithFeatures(featuremgmt.FlagBackgroundPluginInstaller),
|
||||
}
|
||||
|
||||
// Check if the service is disabled
|
||||
if s.IsDisabled() {
|
||||
t.Error("Service should be enabled")
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginexternal"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugininstaller"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||
@@ -124,6 +125,7 @@ var WireSet = wire.NewSet(
|
||||
pluginexternal.ProvideService,
|
||||
plugincontext.ProvideBaseService,
|
||||
wire.Bind(new(plugincontext.BasePluginContextProvider), new(*plugincontext.BaseProvider)),
|
||||
plugininstaller.ProvideService,
|
||||
)
|
||||
|
||||
// WireExtensionSet provides a wire.ProviderSet of plugin providers that can be
|
||||
|
||||
Reference in New Issue
Block a user