| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | package pluginsintegration | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/google/wire" | 
					
						
							| 
									
										
										
										
											2024-03-25 18:23:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | 	"github.com/grafana/grafana-plugin-sdk-go/backend" | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	"github.com/prometheus/client_golang/prometheus" | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-28 17:01:06 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/infra/tracing" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins" | 
					
						
							| 
									
										
										
										
											2023-09-28 18:18:09 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/auth" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/plugins/backendplugin/provider" | 
					
						
							| 
									
										
										
										
											2024-02-27 19:38:02 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/envvars" | 
					
						
							| 
									
										
										
										
											2023-09-12 23:33:48 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/log" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/client" | 
					
						
							| 
									
										
										
										
											2023-03-29 18:55:55 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/filestore" | 
					
						
							| 
									
										
										
										
											2023-08-03 00:29:12 +08:00
										 |  |  | 	pluginLoader "github.com/grafana/grafana/pkg/plugins/manager/loader" | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Remote patterns fetching (#69843)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* Fix merge conflict on updated angular patterns
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* Moved dynamic inspector into pluginsintegration
* Move gcom angulardetectorsprovider into pluginsintegration
* Log errUnknownPatternType at debug level
* re-generate feature flags
* fix error log
											
										 
											2023-06-26 21:33:21 +08:00
										 |  |  | 	pAngularInspector "github.com/grafana/grafana/pkg/plugins/manager/loader/angular/angularinspector" | 
					
						
							| 
									
										
										
										
											2023-01-27 22:08:17 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/loader/assetpath" | 
					
						
							| 
									
										
										
										
											2023-03-20 21:35:49 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/loader/finder" | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/pipeline/bootstrap" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/pipeline/discovery" | 
					
						
							| 
									
										
										
										
											2023-08-03 00:29:12 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/pipeline/initialization" | 
					
						
							| 
									
										
										
										
											2023-08-04 17:57:49 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/pipeline/termination" | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/pipeline/validation" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/process" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/registry" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/signature" | 
					
						
							| 
									
										
										
										
											2023-02-28 22:27:11 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/manager/sources" | 
					
						
							| 
									
										
										
										
											2023-01-27 22:08:17 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/pluginscdn" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins/repo" | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/caching" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/services/featuremgmt" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/oauthtoken" | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Add database cache store for remote patterns (#70693)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* WIP: Angular: cache patterns in db, moved gcom into pluginsintegration
More similar to signing keys fetching
* Rename package, refactoring
* try to solve circular import
* Fix merge conflict on updated angular patterns
* Fix circular imports
* Fix wire gen
* Add docstrings, refactoring
* Removed angualrdetectorsprovider dependency into angularpatternsstore
* Moved GCOM test files
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* refactoring
* lint
* Fix angularinspector TestProvideService
* cleanup
* Await initial restore
* Register dynamicAngularDetector background service
* Removed static detectors provider from pluginsintegration
* Add tests for kvstore
* Add more tests
* order imports in dynamic_test.go
* Fix potential panic in dynamic_test
* Add "runs the job periodically" test
* lint
* add timeout to test
* refactoring
* Removed context.Context from DetectorsProvider
* Refactoring, ensure angular dynamic background service is not started if feature flag is off
* Fix deadlock on startup
* Fix angulardetectorsprovider tests
* Revert "Removed context.Context from DetectorsProvider"
This reverts commit 4e8c6dded70844709400fa0ce4ce45e66c8458ca.
* Fix wrong argument number in dynamic_teset
* Standardize gcom http client
* Reduce context timeout for angular inspector in plugins loader
* Simplify initial restore logic
* Fix dynamic detectors provider tests
* Chore: removed angulardetector/provider.go
* Add more tests
* Removed backgroundJob interface, PR review feedback
* Update tests
* PR review feedback: remove ErrNoCachedValue from kv store Get
* Update tests
* PR review feedback: add IsDisabled and remove nop background srevice
* Update tests
* Remove initialRestore channel, use mux instead
* Removed backgroundJobInterval, use package-level variable instead
* Add TestDynamicAngularDetectorsProviderBackgroundService
* Removed timeouts
* pr review feedback: restore from store before returning the service
* Update tests
* Log duration on startup restore and cron run
* Switch cron job start log to debug level
* Do not attempt to restore if disabled
											
										 
											2023-07-06 22:34:27 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider" | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Remote patterns fetching (#69843)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* Fix merge conflict on updated angular patterns
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* Moved dynamic inspector into pluginsintegration
* Move gcom angulardetectorsprovider into pluginsintegration
* Log errUnknownPatternType at debug level
* re-generate feature flags
* fix error log
											
										 
											2023-06-26 21:33:21 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/angularinspector" | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Add database cache store for remote patterns (#70693)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* WIP: Angular: cache patterns in db, moved gcom into pluginsintegration
More similar to signing keys fetching
* Rename package, refactoring
* try to solve circular import
* Fix merge conflict on updated angular patterns
* Fix circular imports
* Fix wire gen
* Add docstrings, refactoring
* Removed angualrdetectorsprovider dependency into angularpatternsstore
* Moved GCOM test files
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* refactoring
* lint
* Fix angularinspector TestProvideService
* cleanup
* Await initial restore
* Register dynamicAngularDetector background service
* Removed static detectors provider from pluginsintegration
* Add tests for kvstore
* Add more tests
* order imports in dynamic_test.go
* Fix potential panic in dynamic_test
* Add "runs the job periodically" test
* lint
* add timeout to test
* refactoring
* Removed context.Context from DetectorsProvider
* Refactoring, ensure angular dynamic background service is not started if feature flag is off
* Fix deadlock on startup
* Fix angulardetectorsprovider tests
* Revert "Removed context.Context from DetectorsProvider"
This reverts commit 4e8c6dded70844709400fa0ce4ce45e66c8458ca.
* Fix wrong argument number in dynamic_teset
* Standardize gcom http client
* Reduce context timeout for angular inspector in plugins loader
* Simplify initial restore logic
* Fix dynamic detectors provider tests
* Chore: removed angulardetector/provider.go
* Add more tests
* Removed backgroundJob interface, PR review feedback
* Update tests
* PR review feedback: remove ErrNoCachedValue from kv store Get
* Update tests
* PR review feedback: add IsDisabled and remove nop background srevice
* Update tests
* Remove initialRestore channel, use mux instead
* Removed backgroundJobInterval, use package-level variable instead
* Add TestDynamicAngularDetectorsProviderBackgroundService
* Removed timeouts
* pr review feedback: restore from store before returning the service
* Update tests
* Log duration on startup restore and cron run
* Switch cron job start log to debug level
* Do not attempt to restore if disabled
											
										 
											2023-07-06 22:34:27 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/angularpatternsstore" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/clientmiddleware" | 
					
						
							| 
									
										
										
										
											2023-04-27 23:54:28 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever/dynamic" | 
					
						
							| 
									
										
										
										
											2023-04-25 19:01:49 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/keystore" | 
					
						
							| 
									
										
										
										
											2023-03-27 17:15:37 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/licensing" | 
					
						
							| 
									
										
										
										
											2023-08-03 00:29:12 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/loader" | 
					
						
							| 
									
										
										
										
											2024-07-29 18:18:43 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/managedplugins" | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline" | 
					
						
							| 
									
										
										
										
											2024-09-09 17:38:35 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginassets" | 
					
						
							| 
									
										
										
										
											2024-02-27 19:38:02 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginconfig" | 
					
						
							| 
									
										
										
										
											2024-05-28 21:59:06 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext" | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs" | 
					
						
							| 
									
										
										
										
											2024-02-07 22:17:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginexternal" | 
					
						
							| 
									
										
										
										
											2024-08-12 22:39:31 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/plugininstaller" | 
					
						
							| 
									
										
										
										
											2023-03-08 00:22:30 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings" | 
					
						
							|  |  |  | 	pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service" | 
					
						
							| 
									
										
										
										
											2023-09-11 19:59:24 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore" | 
					
						
							| 
									
										
										
										
											2023-12-15 00:33:29 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/renderer" | 
					
						
							| 
									
										
										
										
											2023-06-26 22:38:43 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/serviceregistration" | 
					
						
							| 
									
										
										
										
											2023-12-15 00:33:29 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/rendering" | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/setting" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // WireSet provides a wire.ProviderSet of plugin providers.
 | 
					
						
							|  |  |  | var WireSet = wire.NewSet( | 
					
						
							| 
									
										
										
										
											2024-02-27 19:38:02 +08:00
										 |  |  | 	pluginconfig.ProvidePluginManagementConfig, | 
					
						
							|  |  |  | 	pluginconfig.ProvidePluginInstanceConfig, | 
					
						
							|  |  |  | 	pluginconfig.NewEnvVarsProvider, | 
					
						
							|  |  |  | 	wire.Bind(new(envvars.Provider), new(*pluginconfig.EnvVarsProvider)), | 
					
						
							|  |  |  | 	pluginconfig.NewRequestConfigProvider, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginconfig.PluginRequestConfigProvider), new(*pluginconfig.RequestConfigProvider)), | 
					
						
							| 
									
										
										
										
											2023-09-11 19:59:24 +08:00
										 |  |  | 	pluginstore.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginstore.Store), new(*pluginstore.Service)), | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.SecretsPluginManager), new(*pluginstore.Service)), | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.StaticRouteResolver), new(*pluginstore.Service)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	process.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-08-16 16:46:00 +08:00
										 |  |  | 	wire.Bind(new(process.Manager), new(*process.Service)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	coreplugin.ProvideCoreRegistry, | 
					
						
							| 
									
										
										
										
											2023-01-27 22:08:17 +08:00
										 |  |  | 	pluginscdn.ProvideService, | 
					
						
							|  |  |  | 	assetpath.ProvideService, | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Add database cache store for remote patterns (#70693)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* WIP: Angular: cache patterns in db, moved gcom into pluginsintegration
More similar to signing keys fetching
* Rename package, refactoring
* try to solve circular import
* Fix merge conflict on updated angular patterns
* Fix circular imports
* Fix wire gen
* Add docstrings, refactoring
* Removed angualrdetectorsprovider dependency into angularpatternsstore
* Moved GCOM test files
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* refactoring
* lint
* Fix angularinspector TestProvideService
* cleanup
* Await initial restore
* Register dynamicAngularDetector background service
* Removed static detectors provider from pluginsintegration
* Add tests for kvstore
* Add more tests
* order imports in dynamic_test.go
* Fix potential panic in dynamic_test
* Add "runs the job periodically" test
* lint
* add timeout to test
* refactoring
* Removed context.Context from DetectorsProvider
* Refactoring, ensure angular dynamic background service is not started if feature flag is off
* Fix deadlock on startup
* Fix angulardetectorsprovider tests
* Revert "Removed context.Context from DetectorsProvider"
This reverts commit 4e8c6dded70844709400fa0ce4ce45e66c8458ca.
* Fix wrong argument number in dynamic_teset
* Standardize gcom http client
* Reduce context timeout for angular inspector in plugins loader
* Simplify initial restore logic
* Fix dynamic detectors provider tests
* Chore: removed angulardetector/provider.go
* Add more tests
* Removed backgroundJob interface, PR review feedback
* Update tests
* PR review feedback: remove ErrNoCachedValue from kv store Get
* Update tests
* PR review feedback: add IsDisabled and remove nop background srevice
* Update tests
* Remove initialRestore channel, use mux instead
* Removed backgroundJobInterval, use package-level variable instead
* Add TestDynamicAngularDetectorsProviderBackgroundService
* Removed timeouts
* pr review feedback: restore from store before returning the service
* Update tests
* Log duration on startup restore and cron run
* Switch cron job start log to debug level
* Do not attempt to restore if disabled
											
										 
											2023-07-06 22:34:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 	pipeline.ProvideDiscoveryStage, | 
					
						
							|  |  |  | 	wire.Bind(new(discovery.Discoverer), new(*discovery.Discovery)), | 
					
						
							|  |  |  | 	pipeline.ProvideBootstrapStage, | 
					
						
							|  |  |  | 	wire.Bind(new(bootstrap.Bootstrapper), new(*bootstrap.Bootstrap)), | 
					
						
							| 
									
										
										
										
											2023-08-03 00:29:12 +08:00
										 |  |  | 	pipeline.ProvideInitializationStage, | 
					
						
							|  |  |  | 	wire.Bind(new(initialization.Initializer), new(*initialization.Initialize)), | 
					
						
							| 
									
										
										
										
											2023-08-04 17:57:49 +08:00
										 |  |  | 	pipeline.ProvideTerminationStage, | 
					
						
							|  |  |  | 	wire.Bind(new(termination.Terminator), new(*termination.Terminate)), | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	pipeline.ProvideValidationStage, | 
					
						
							|  |  |  | 	wire.Bind(new(validation.Validator), new(*validation.Validate)), | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Add database cache store for remote patterns (#70693)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* WIP: Angular: cache patterns in db, moved gcom into pluginsintegration
More similar to signing keys fetching
* Rename package, refactoring
* try to solve circular import
* Fix merge conflict on updated angular patterns
* Fix circular imports
* Fix wire gen
* Add docstrings, refactoring
* Removed angualrdetectorsprovider dependency into angularpatternsstore
* Moved GCOM test files
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* refactoring
* lint
* Fix angularinspector TestProvideService
* cleanup
* Await initial restore
* Register dynamicAngularDetector background service
* Removed static detectors provider from pluginsintegration
* Add tests for kvstore
* Add more tests
* order imports in dynamic_test.go
* Fix potential panic in dynamic_test
* Add "runs the job periodically" test
* lint
* add timeout to test
* refactoring
* Removed context.Context from DetectorsProvider
* Refactoring, ensure angular dynamic background service is not started if feature flag is off
* Fix deadlock on startup
* Fix angulardetectorsprovider tests
* Revert "Removed context.Context from DetectorsProvider"
This reverts commit 4e8c6dded70844709400fa0ce4ce45e66c8458ca.
* Fix wrong argument number in dynamic_teset
* Standardize gcom http client
* Reduce context timeout for angular inspector in plugins loader
* Simplify initial restore logic
* Fix dynamic detectors provider tests
* Chore: removed angulardetector/provider.go
* Add more tests
* Removed backgroundJob interface, PR review feedback
* Update tests
* PR review feedback: remove ErrNoCachedValue from kv store Get
* Update tests
* PR review feedback: add IsDisabled and remove nop background srevice
* Update tests
* Remove initialRestore channel, use mux instead
* Removed backgroundJobInterval, use package-level variable instead
* Add TestDynamicAngularDetectorsProviderBackgroundService
* Removed timeouts
* pr review feedback: restore from store before returning the service
* Update tests
* Log duration on startup restore and cron run
* Switch cron job start log to debug level
* Do not attempt to restore if disabled
											
										 
											2023-07-06 22:34:27 +08:00
										 |  |  | 	angularpatternsstore.ProvideService, | 
					
						
							|  |  |  | 	angulardetectorsprovider.ProvideDynamic, | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Remote patterns fetching (#69843)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* Fix merge conflict on updated angular patterns
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* Moved dynamic inspector into pluginsintegration
* Move gcom angulardetectorsprovider into pluginsintegration
* Log errUnknownPatternType at debug level
* re-generate feature flags
* fix error log
											
										 
											2023-06-26 21:33:21 +08:00
										 |  |  | 	angularinspector.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(pAngularInspector.Inspector), new(*angularinspector.Service)), | 
					
						
							| 
									
										
											  
											
												Plugins: Angular detector: Add database cache store for remote patterns (#70693)
* Plugins: Angular detector: Remote patterns fetching
* Renamed PatternType to GCOMPatternType
* Renamed files
* Renamed more files
* Moved files again
* Add type checks, unexport GCOM structs
* Cache failures, update log messages, fix GCOM URL
* Fail silently for unknown pattern types, update docstrings
* Fix tests
* Rename gcomPattern.Value to gcomPattern.Pattern
* Refactoring
* Add FlagPluginsRemoteAngularDetectionPatterns feature flag
* Fix tests
* Re-generate feature flags
* Add TestProvideInspector, renamed TestDefaultStaticDetectorsInspector
* Add TestProvideInspector
* Add TestContainsBytesDetector and TestRegexDetector
* Renamed getter to provider
* More tests
* TestStaticDetectorsProvider, TestSequenceDetectorsProvider
* GCOM tests
* Lint
* Made detector.detect unexported, updated docstrings
* Allow changing grafana.com URL
* Fix API path, add more logs
* Update tryUpdateRemoteDetectors docstring
* Use angulardetector http client
* Return false, nil if module.js does not exist
* Chore: Split angualrdetector into angularinspector and angulardetector packages
Moved files around, changed references and fixed tests:
- Split the old angulardetector package into angular/angulardetector and angular/angularinspector
- angulardetector provides the detection structs/interfaces (Detector, DetectorsProvider...)
- angularinspector provides the actual angular detection service used directly in pluginsintegration
- Exported most of the stuff that was private and now put into angulardetector, as it is not required by angularinspector
* Renamed detector.go -> angulardetector.go and inspector.go -> angularinspector.go
Forgot to rename those two files to match the package's names
* Renamed angularinspector.ProvideInspector to angularinspector.ProvideService
* Renamed "harcoded" to "static" and "remote" to "dynamic"
from PR review, matches the same naming schema used for signing keys fetching
* WIP: Angular: cache patterns in db, moved gcom into pluginsintegration
More similar to signing keys fetching
* Rename package, refactoring
* try to solve circular import
* Fix merge conflict on updated angular patterns
* Fix circular imports
* Fix wire gen
* Add docstrings, refactoring
* Removed angualrdetectorsprovider dependency into angularpatternsstore
* Moved GCOM test files
* Removed GCOM cache
* Renamed Detect to DetectAngular and Detector to AngularDetector
* Fix call to NewGCOMDetectorsProvider in newDynamicInspector
* Removed unused test function newError500GCOMScenario
* Added angularinspector service definition in pluginsintegration
* refactoring
* lint
* Fix angularinspector TestProvideService
* cleanup
* Await initial restore
* Register dynamicAngularDetector background service
* Removed static detectors provider from pluginsintegration
* Add tests for kvstore
* Add more tests
* order imports in dynamic_test.go
* Fix potential panic in dynamic_test
* Add "runs the job periodically" test
* lint
* add timeout to test
* refactoring
* Removed context.Context from DetectorsProvider
* Refactoring, ensure angular dynamic background service is not started if feature flag is off
* Fix deadlock on startup
* Fix angulardetectorsprovider tests
* Revert "Removed context.Context from DetectorsProvider"
This reverts commit 4e8c6dded70844709400fa0ce4ce45e66c8458ca.
* Fix wrong argument number in dynamic_teset
* Standardize gcom http client
* Reduce context timeout for angular inspector in plugins loader
* Simplify initial restore logic
* Fix dynamic detectors provider tests
* Chore: removed angulardetector/provider.go
* Add more tests
* Removed backgroundJob interface, PR review feedback
* Update tests
* PR review feedback: remove ErrNoCachedValue from kv store Get
* Update tests
* PR review feedback: add IsDisabled and remove nop background srevice
* Update tests
* Remove initialRestore channel, use mux instead
* Removed backgroundJobInterval, use package-level variable instead
* Add TestDynamicAngularDetectorsProviderBackgroundService
* Removed timeouts
* pr review feedback: restore from store before returning the service
* Update tests
* Log duration on startup restore and cron run
* Switch cron job start log to debug level
* Do not attempt to restore if disabled
											
										 
											2023-07-06 22:34:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	signature.ProvideValidatorService, | 
					
						
							|  |  |  | 	wire.Bind(new(signature.Validator), new(*signature.Validation)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	loader.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-08-03 00:29:12 +08:00
										 |  |  | 	wire.Bind(new(pluginLoader.Service), new(*loader.Loader)), | 
					
						
							| 
									
										
										
										
											2024-04-11 22:18:04 +08:00
										 |  |  | 	pluginerrs.ProvideErrorTracker, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginerrs.ErrorTracker), new(*pluginerrs.ErrorRegistry)), | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	pluginerrs.ProvideStore, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.ErrorResolver), new(*pluginerrs.Store)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	registry.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(registry.Service), new(*registry.InMemory)), | 
					
						
							|  |  |  | 	repo.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(repo.Service), new(*repo.Manager)), | 
					
						
							| 
									
										
										
										
											2023-01-19 01:02:54 +08:00
										 |  |  | 	licensing.ProvideLicensing, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.Licensing), new(*licensing.Service)), | 
					
						
							| 
									
										
										
										
											2023-03-20 21:35:49 +08:00
										 |  |  | 	wire.Bind(new(sources.Registry), new(*sources.Service)), | 
					
						
							| 
									
										
										
										
											2023-02-28 22:27:11 +08:00
										 |  |  | 	sources.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-03-08 00:22:30 +08:00
										 |  |  | 	pluginSettings.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginsettings.Service), new(*pluginSettings.Service)), | 
					
						
							| 
									
										
										
										
											2023-03-29 18:55:55 +08:00
										 |  |  | 	filestore.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.FileStore), new(*filestore.Service)), | 
					
						
							| 
									
										
										
										
											2023-04-18 22:12:05 +08:00
										 |  |  | 	wire.Bind(new(plugins.SignatureCalculator), new(*signature.Signature)), | 
					
						
							|  |  |  | 	signature.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-04-25 19:01:49 +08:00
										 |  |  | 	wire.Bind(new(plugins.KeyStore), new(*keystore.Service)), | 
					
						
							|  |  |  | 	keystore.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-04-27 23:54:28 +08:00
										 |  |  | 	wire.Bind(new(plugins.KeyRetriever), new(*keyretriever.Service)), | 
					
						
							|  |  |  | 	keyretriever.ProvideService, | 
					
						
							|  |  |  | 	dynamic.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-06-26 22:38:43 +08:00
										 |  |  | 	serviceregistration.ProvideService, | 
					
						
							| 
									
										
										
										
											2023-09-28 18:18:09 +08:00
										 |  |  | 	wire.Bind(new(auth.ExternalServiceRegistry), new(*serviceregistration.Service)), | 
					
						
							| 
									
										
										
										
											2023-12-15 00:33:29 +08:00
										 |  |  | 	renderer.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(rendering.PluginManager), new(*renderer.Manager)), | 
					
						
							| 
									
										
										
										
											2024-02-07 22:17:13 +08:00
										 |  |  | 	pluginexternal.ProvideService, | 
					
						
							| 
									
										
										
										
											2024-05-28 21:59:06 +08:00
										 |  |  | 	plugincontext.ProvideBaseService, | 
					
						
							|  |  |  | 	wire.Bind(new(plugincontext.BasePluginContextProvider), new(*plugincontext.BaseProvider)), | 
					
						
							| 
									
										
										
										
											2024-08-12 22:39:31 +08:00
										 |  |  | 	plugininstaller.ProvideService, | 
					
						
							| 
									
										
										
										
											2024-09-09 17:38:35 +08:00
										 |  |  | 	pluginassets.ProvideService, | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // WireExtensionSet provides a wire.ProviderSet of plugin providers that can be
 | 
					
						
							|  |  |  | // extended.
 | 
					
						
							|  |  |  | var WireExtensionSet = wire.NewSet( | 
					
						
							|  |  |  | 	provider.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.BackendFactoryProvider), new(*provider.Service)), | 
					
						
							|  |  |  | 	signature.ProvideOSSAuthorizer, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.PluginLoaderAuthorizer), new(*signature.UnsignedPluginAuthorizer)), | 
					
						
							| 
									
										
										
										
											2023-04-27 16:26:15 +08:00
										 |  |  | 	finder.ProvideLocalFinder, | 
					
						
							| 
									
										
										
										
											2024-07-29 18:18:43 +08:00
										 |  |  | 	wire.Bind(new(finder.Finder), new(*finder.Local)), | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | 	ProvideClientWithMiddlewares, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.Client), new(*backend.MiddlewareHandler)), | 
					
						
							| 
									
										
										
										
											2024-07-29 18:18:43 +08:00
										 |  |  | 	managedplugins.NewNoop, | 
					
						
							|  |  |  | 	wire.Bind(new(managedplugins.Manager), new(*managedplugins.Noop)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | func ProvideClientWithMiddlewares( | 
					
						
							| 
									
										
										
										
											2024-03-11 23:28:46 +08:00
										 |  |  | 	cfg *setting.Cfg, | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	pluginRegistry registry.Service, | 
					
						
							| 
									
										
										
										
											2023-03-28 17:01:06 +08:00
										 |  |  | 	oAuthTokenService oauthtoken.OAuthTokenService, | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | 	tracer tracing.Tracer, | 
					
						
							|  |  |  | 	cachingService caching.CachingService, | 
					
						
							| 
									
										
										
										
											2024-04-05 00:22:31 +08:00
										 |  |  | 	features featuremgmt.FeatureToggles, | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	promRegisterer prometheus.Registerer, | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | ) (*backend.MiddlewareHandler, error) { | 
					
						
							|  |  |  | 	return NewMiddlewareHandler(cfg, pluginRegistry, oAuthTokenService, tracer, cachingService, features, promRegisterer, pluginRegistry) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | func NewMiddlewareHandler( | 
					
						
							| 
									
										
										
										
											2024-03-11 23:28:46 +08:00
										 |  |  | 	cfg *setting.Cfg, | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | 	pluginRegistry registry.Service, oAuthTokenService oauthtoken.OAuthTokenService, | 
					
						
							| 
									
										
										
										
											2024-04-05 00:22:31 +08:00
										 |  |  | 	tracer tracing.Tracer, cachingService caching.CachingService, features featuremgmt.FeatureToggles, | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	promRegisterer prometheus.Registerer, registry registry.Service, | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | ) (*backend.MiddlewareHandler, error) { | 
					
						
							| 
									
										
										
										
											2024-03-11 23:28:46 +08:00
										 |  |  | 	c := client.ProvideService(pluginRegistry) | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	middlewares := CreateMiddlewares(cfg, oAuthTokenService, tracer, cachingService, features, promRegisterer, registry) | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | 	return backend.HandlerFromMiddlewares(c, middlewares...) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-30 22:33:15 +08:00
										 |  |  | func CreateMiddlewares(cfg *setting.Cfg, oAuthTokenService oauthtoken.OAuthTokenService, tracer tracing.Tracer, cachingService caching.CachingService, features featuremgmt.FeatureToggles, promRegisterer prometheus.Registerer, registry registry.Service) []backend.HandlerMiddleware { | 
					
						
							|  |  |  | 	middlewares := []backend.HandlerMiddleware{ | 
					
						
							| 
									
										
										
										
											2024-02-21 19:57:40 +08:00
										 |  |  | 		clientmiddleware.NewPluginRequestMetaMiddleware(), | 
					
						
							| 
									
										
										
										
											2024-03-22 19:54:35 +08:00
										 |  |  | 		clientmiddleware.NewTracingMiddleware(tracer), | 
					
						
							|  |  |  | 		clientmiddleware.NewMetricsMiddleware(promRegisterer, registry), | 
					
						
							|  |  |  | 		clientmiddleware.NewContextualLoggerMiddleware(), | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if cfg.PluginLogBackendRequests { | 
					
						
							| 
									
										
										
										
											2024-09-02 23:41:26 +08:00
										 |  |  | 		middlewares = append(middlewares, clientmiddleware.NewLoggerMiddleware(log.New("plugin.instrumentation"), registry)) | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	skipCookiesNames := []string{cfg.LoginCookieName} | 
					
						
							| 
									
										
										
										
											2024-03-22 19:54:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	middlewares = append(middlewares, | 
					
						
							| 
									
										
										
										
											2022-12-22 18:15:00 +08:00
										 |  |  | 		clientmiddleware.NewTracingHeaderMiddleware(), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 		clientmiddleware.NewClearAuthHeadersMiddleware(), | 
					
						
							|  |  |  | 		clientmiddleware.NewOAuthTokenMiddleware(oAuthTokenService), | 
					
						
							|  |  |  | 		clientmiddleware.NewCookiesMiddleware(skipCookiesNames), | 
					
						
							| 
									
										
										
										
											2024-01-18 05:53:25 +08:00
										 |  |  | 		clientmiddleware.NewCachingMiddlewareWithFeatureManager(cachingService, features), | 
					
						
							| 
									
										
										
										
											2024-08-21 21:30:17 +08:00
										 |  |  | 		clientmiddleware.NewForwardIDMiddleware(), | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 22:28:25 +08:00
										 |  |  | 	if cfg.SendUserHeader { | 
					
						
							|  |  |  | 		middlewares = append(middlewares, clientmiddleware.NewUserHeaderMiddleware()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-01 01:09:24 +08:00
										 |  |  | 	if cfg.IPRangeACEnabled { | 
					
						
							|  |  |  | 		middlewares = append(middlewares, clientmiddleware.NewHostedGrafanaACHeaderMiddleware(cfg)) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-21 20:25:58 +08:00
										 |  |  | 	middlewares = append(middlewares, clientmiddleware.NewHTTPClientMiddleware()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-21 19:57:40 +08:00
										 |  |  | 	// StatusSourceMiddleware should be at the very bottom, or any middlewares below it won't see the
 | 
					
						
							|  |  |  | 	// correct status source in their context.Context
 | 
					
						
							|  |  |  | 	middlewares = append(middlewares, clientmiddleware.NewStatusSourceMiddleware()) | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	return middlewares | 
					
						
							|  |  |  | } |