Rendering: Fix plugin initialization (#80013)

This commit is contained in:
Agnès Toulet 2024-01-04 11:30:01 +01:00 committed by GitHub
parent b2b4e8f68d
commit 1cec6195f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,7 @@ type RenderingService struct {
version string
versionMutex sync.RWMutex
capabilities []Capability
pluginAvailable bool
perRequestRenderKeyProvider renderKeyProvider
Cfg *setting.Cfg
@ -108,6 +109,8 @@ func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager, remo
}
}
_, exists := rm.Renderer(context.Background())
s := &RenderingService{
perRequestRenderKeyProvider: renderKeyProvider,
capabilities: []Capability{
@ -131,6 +134,7 @@ func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager, remo
log: logger,
domain: domain,
sanitizeURL: sanitizeURL,
pluginAvailable: exists,
}
gob.Register(&RenderUser{})
@ -200,17 +204,12 @@ func (rs *RenderingService) Run(ctx context.Context) error {
return nil
}
func (rs *RenderingService) pluginAvailable(ctx context.Context) bool {
_, exists := rs.RendererPluginManager.Renderer(ctx)
return exists
}
func (rs *RenderingService) remoteAvailable() bool {
return rs.Cfg.RendererUrl != ""
}
func (rs *RenderingService) IsAvailable(ctx context.Context) bool {
return rs.remoteAvailable() || rs.pluginAvailable(ctx)
return rs.remoteAvailable() || rs.pluginAvailable
}
func (rs *RenderingService) Version() string {