| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | package pluginsintegration | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/google/wire" | 
					
						
							| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2023-04-05 20:40:08 +08:00
										 |  |  | 	pCfg "github.com/grafana/grafana/pkg/plugins/config" | 
					
						
							| 
									
										
										
										
											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-05 20:40:08 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/config" | 
					
						
							| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2023-07-27 21:29:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline" | 
					
						
							| 
									
										
										
										
											2023-03-08 00:22:30 +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" | 
					
						
							| 
									
										
										
										
											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-06-26 22:38:43 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/pluginsintegration/serviceregistration" | 
					
						
							| 
									
										
										
										
											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( | 
					
						
							|  |  |  | 	config.ProvideConfig, | 
					
						
							| 
									
										
										
										
											2023-09-11 19:59:24 +08:00
										 |  |  | 	pluginstore.ProvideService, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginstore.Store), new(*pluginstore.Service)), | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.RendererManager), 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)), | 
					
						
							| 
									
										
										
										
											2023-08-10 00:25:28 +08:00
										 |  |  | 	pluginerrs.ProvideSignatureErrorTracker, | 
					
						
							|  |  |  | 	wire.Bind(new(pluginerrs.SignatureErrorTracker), new(*pluginerrs.SignatureErrorRegistry)), | 
					
						
							|  |  |  | 	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)), | 
					
						
							|  |  |  | 	plugincontext.ProvideService, | 
					
						
							| 
									
										
										
										
											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)), | 
					
						
							| 
									
										
										
										
											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-03-20 21:35:49 +08:00
										 |  |  | 	wire.Bind(new(finder.Finder), new(*finder.Local)), | 
					
						
							| 
									
										
										
										
											2023-04-27 16:26:15 +08:00
										 |  |  | 	finder.ProvideLocalFinder, | 
					
						
							| 
									
										
										
										
											2023-10-24 19:06:18 +08:00
										 |  |  | 	ProvideClientDecorator, | 
					
						
							|  |  |  | 	wire.Bind(new(plugins.Client), new(*client.Decorator)), | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | func ProvideClientDecorator( | 
					
						
							|  |  |  | 	cfg *setting.Cfg, pCfg *pCfg.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, | 
					
						
							|  |  |  | 	features *featuremgmt.FeatureManager, | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	promRegisterer prometheus.Registerer, | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | ) (*client.Decorator, error) { | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	return NewClientDecorator(cfg, pCfg, pluginRegistry, oAuthTokenService, tracer, cachingService, features, promRegisterer, pluginRegistry) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | func NewClientDecorator( | 
					
						
							|  |  |  | 	cfg *setting.Cfg, pCfg *pCfg.Cfg, | 
					
						
							|  |  |  | 	pluginRegistry registry.Service, oAuthTokenService oauthtoken.OAuthTokenService, | 
					
						
							|  |  |  | 	tracer tracing.Tracer, cachingService caching.CachingService, features *featuremgmt.FeatureManager, | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	promRegisterer prometheus.Registerer, registry registry.Service, | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | ) (*client.Decorator, error) { | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	c := client.ProvideService(pluginRegistry, pCfg) | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | 	middlewares := CreateMiddlewares(cfg, oAuthTokenService, tracer, cachingService, features, promRegisterer, registry) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	return client.NewDecorator(c, middlewares...) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-09 20:12:57 +08:00
										 |  |  | func CreateMiddlewares(cfg *setting.Cfg, oAuthTokenService oauthtoken.OAuthTokenService, tracer tracing.Tracer, cachingService caching.CachingService, features *featuremgmt.FeatureManager, promRegisterer prometheus.Registerer, registry registry.Service) []plugins.ClientMiddleware { | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	var middlewares []plugins.ClientMiddleware | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if features.IsEnabled(featuremgmt.FlagPluginsInstrumentationStatusSource) { | 
					
						
							|  |  |  | 		middlewares = []plugins.ClientMiddleware{ | 
					
						
							|  |  |  | 			clientmiddleware.NewPluginRequestMetaMiddleware(), | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	skipCookiesNames := []string{cfg.LoginCookieName} | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	middlewares = append(middlewares, | 
					
						
							| 
									
										
										
										
											2023-03-28 17:01:06 +08:00
										 |  |  | 		clientmiddleware.NewTracingMiddleware(tracer), | 
					
						
							| 
									
										
										
										
											2023-10-17 16:27:45 +08:00
										 |  |  | 		clientmiddleware.NewMetricsMiddleware(promRegisterer, registry, features), | 
					
						
							| 
									
										
										
										
											2023-10-11 18:42:32 +08:00
										 |  |  | 		clientmiddleware.NewContextualLoggerMiddleware(), | 
					
						
							| 
									
										
										
										
											2023-10-17 17:09:01 +08:00
										 |  |  | 		clientmiddleware.NewLoggerMiddleware(cfg, log.New("plugin.instrumentation"), features), | 
					
						
							| 
									
										
										
										
											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), | 
					
						
							| 
									
										
										
										
											2023-04-26 01:44:32 +08:00
										 |  |  | 		clientmiddleware.NewResourceResponseMiddleware(), | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	) | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | 	// Placing the new service implementation behind a feature flag until it is known to be stable
 | 
					
						
							|  |  |  | 	if features.IsEnabled(featuremgmt.FlagUseCachingService) { | 
					
						
							| 
									
										
										
										
											2023-07-21 23:34:07 +08:00
										 |  |  | 		middlewares = append(middlewares, clientmiddleware.NewCachingMiddlewareWithFeatureManager(cachingService, features)) | 
					
						
							| 
									
										
										
										
											2023-04-13 00:30:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-02 15:14:10 +08:00
										 |  |  | 	if features.IsEnabled(featuremgmt.FlagIdForwarding) { | 
					
						
							|  |  |  | 		middlewares = append(middlewares, clientmiddleware.NewForwardIDMiddleware()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 22:28:25 +08:00
										 |  |  | 	if cfg.SendUserHeader { | 
					
						
							|  |  |  | 		middlewares = append(middlewares, clientmiddleware.NewUserHeaderMiddleware()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-21 20:25:58 +08:00
										 |  |  | 	middlewares = append(middlewares, clientmiddleware.NewHTTPClientMiddleware()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 20:42:39 +08:00
										 |  |  | 	if features.IsEnabled(featuremgmt.FlagPluginsInstrumentationStatusSource) { | 
					
						
							|  |  |  | 		// 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()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-02 02:08:36 +08:00
										 |  |  | 	return middlewares | 
					
						
							|  |  |  | } |