2022-12-01 12:08:36 -06:00
|
|
|
package pluginsintegration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/wire"
|
2024-03-25 05:23:27 -05:00
|
|
|
|
2023-10-09 07:12:57 -05:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2023-07-27 08:29:13 -05:00
|
|
|
|
2023-03-28 04:01:06 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
2023-09-28 05:18:09 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/auth"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin/provider"
|
2024-02-27 05:38:02 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/envvars"
|
2023-09-12 10:33:48 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/log"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/client"
|
2023-03-29 05:55:55 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/filestore"
|
2023-08-02 11:29:12 -05: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 08:33:21 -05:00
|
|
|
pAngularInspector "github.com/grafana/grafana/pkg/plugins/manager/loader/angular/angularinspector"
|
2023-01-27 08:08:17 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/loader/assetpath"
|
2023-03-20 08:35:49 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/loader/finder"
|
2023-07-27 08:29:13 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/bootstrap"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/discovery"
|
2023-08-02 11:29:12 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/initialization"
|
2023-08-04 04:57:49 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/termination"
|
2023-08-09 11:25:28 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/validation"
|
2022-12-01 12:08:36 -06: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 08:27:11 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
2023-01-27 08:08:17 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/repo"
|
2023-04-12 11:30:33 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/caching"
|
|
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
2022-12-01 12:08:36 -06: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 09:34:27 -05: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 08:33:21 -05: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 09:34:27 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/angularpatternsstore"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/clientmiddleware"
|
2023-04-27 10:54:28 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever"
|
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever/dynamic"
|
2023-04-25 06:01:49 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/keystore"
|
2023-03-27 04:15:37 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/licensing"
|
2023-08-02 11:29:12 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/loader"
|
2023-07-27 08:29:13 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline"
|
2024-02-27 05:38:02 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginconfig"
|
2023-08-09 11:25:28 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
2024-02-07 08:17:13 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginexternal"
|
2023-03-07 10:22:30 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
|
|
|
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service"
|
2023-09-11 06:59:24 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
2023-12-14 10:33:29 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/renderer"
|
2023-06-26 09:38:43 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/serviceregistration"
|
2023-12-14 10:33:29 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
2022-12-01 12:08:36 -06:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
// WireSet provides a wire.ProviderSet of plugin providers.
|
|
|
|
var WireSet = wire.NewSet(
|
2024-02-27 05:38:02 -06: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 06:59:24 -05: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-01 12:08:36 -06:00
|
|
|
process.ProvideService,
|
2023-08-16 03:46:00 -05:00
|
|
|
wire.Bind(new(process.Manager), new(*process.Service)),
|
2022-12-01 12:08:36 -06:00
|
|
|
coreplugin.ProvideCoreRegistry,
|
2023-01-27 08:08:17 -06: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 09:34:27 -05:00
|
|
|
|
2023-07-27 08:29:13 -05:00
|
|
|
pipeline.ProvideDiscoveryStage,
|
|
|
|
wire.Bind(new(discovery.Discoverer), new(*discovery.Discovery)),
|
|
|
|
pipeline.ProvideBootstrapStage,
|
|
|
|
wire.Bind(new(bootstrap.Bootstrapper), new(*bootstrap.Bootstrap)),
|
2023-08-02 11:29:12 -05:00
|
|
|
pipeline.ProvideInitializationStage,
|
|
|
|
wire.Bind(new(initialization.Initializer), new(*initialization.Initialize)),
|
2023-08-04 04:57:49 -05:00
|
|
|
pipeline.ProvideTerminationStage,
|
|
|
|
wire.Bind(new(termination.Terminator), new(*termination.Terminate)),
|
2023-08-09 11:25:28 -05:00
|
|
|
pipeline.ProvideValidationStage,
|
|
|
|
wire.Bind(new(validation.Validator), new(*validation.Validate)),
|
2023-07-27 08:29:13 -05: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 09:34:27 -05: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 08:33:21 -05: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 09:34:27 -05:00
|
|
|
|
2023-08-09 11:25:28 -05:00
|
|
|
signature.ProvideValidatorService,
|
|
|
|
wire.Bind(new(signature.Validator), new(*signature.Validation)),
|
2022-12-01 12:08:36 -06:00
|
|
|
loader.ProvideService,
|
2023-08-02 11:29:12 -05:00
|
|
|
wire.Bind(new(pluginLoader.Service), new(*loader.Loader)),
|
2024-04-11 09:18:04 -05:00
|
|
|
pluginerrs.ProvideErrorTracker,
|
|
|
|
wire.Bind(new(pluginerrs.ErrorTracker), new(*pluginerrs.ErrorRegistry)),
|
2023-08-09 11:25:28 -05:00
|
|
|
pluginerrs.ProvideStore,
|
|
|
|
wire.Bind(new(plugins.ErrorResolver), new(*pluginerrs.Store)),
|
2022-12-01 12:08:36 -06:00
|
|
|
registry.ProvideService,
|
|
|
|
wire.Bind(new(registry.Service), new(*registry.InMemory)),
|
|
|
|
repo.ProvideService,
|
|
|
|
wire.Bind(new(repo.Service), new(*repo.Manager)),
|
2023-01-18 11:02:54 -06:00
|
|
|
licensing.ProvideLicensing,
|
|
|
|
wire.Bind(new(plugins.Licensing), new(*licensing.Service)),
|
2023-03-20 08:35:49 -05:00
|
|
|
wire.Bind(new(sources.Registry), new(*sources.Service)),
|
2023-02-28 08:27:11 -06:00
|
|
|
sources.ProvideService,
|
2023-03-07 10:22:30 -06:00
|
|
|
pluginSettings.ProvideService,
|
|
|
|
wire.Bind(new(pluginsettings.Service), new(*pluginSettings.Service)),
|
2023-03-29 05:55:55 -05:00
|
|
|
filestore.ProvideService,
|
|
|
|
wire.Bind(new(plugins.FileStore), new(*filestore.Service)),
|
2023-04-18 09:12:05 -05:00
|
|
|
wire.Bind(new(plugins.SignatureCalculator), new(*signature.Signature)),
|
|
|
|
signature.ProvideService,
|
2023-04-25 06:01:49 -05:00
|
|
|
wire.Bind(new(plugins.KeyStore), new(*keystore.Service)),
|
|
|
|
keystore.ProvideService,
|
2023-04-27 10:54:28 -05:00
|
|
|
wire.Bind(new(plugins.KeyRetriever), new(*keyretriever.Service)),
|
|
|
|
keyretriever.ProvideService,
|
|
|
|
dynamic.ProvideService,
|
2023-06-26 09:38:43 -05:00
|
|
|
serviceregistration.ProvideService,
|
2023-09-28 05:18:09 -05:00
|
|
|
wire.Bind(new(auth.ExternalServiceRegistry), new(*serviceregistration.Service)),
|
2023-12-14 10:33:29 -06:00
|
|
|
renderer.ProvideService,
|
|
|
|
wire.Bind(new(rendering.PluginManager), new(*renderer.Manager)),
|
2024-02-07 08:17:13 -06:00
|
|
|
pluginexternal.ProvideService,
|
2022-12-01 12:08:36 -06: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 08:35:49 -05:00
|
|
|
wire.Bind(new(finder.Finder), new(*finder.Local)),
|
2023-04-27 03:26:15 -05:00
|
|
|
finder.ProvideLocalFinder,
|
2023-10-24 06:06:18 -05:00
|
|
|
ProvideClientDecorator,
|
|
|
|
wire.Bind(new(plugins.Client), new(*client.Decorator)),
|
2022-12-01 12:08:36 -06:00
|
|
|
)
|
|
|
|
|
2023-04-12 11:30:33 -05:00
|
|
|
func ProvideClientDecorator(
|
2024-03-11 10:28:46 -05:00
|
|
|
cfg *setting.Cfg,
|
2022-12-01 12:08:36 -06:00
|
|
|
pluginRegistry registry.Service,
|
2023-03-28 04:01:06 -05:00
|
|
|
oAuthTokenService oauthtoken.OAuthTokenService,
|
2023-04-12 11:30:33 -05:00
|
|
|
tracer tracing.Tracer,
|
|
|
|
cachingService caching.CachingService,
|
2024-04-04 11:22:31 -05:00
|
|
|
features featuremgmt.FeatureToggles,
|
2023-10-09 07:12:57 -05:00
|
|
|
promRegisterer prometheus.Registerer,
|
2023-04-12 11:30:33 -05:00
|
|
|
) (*client.Decorator, error) {
|
2024-03-11 10:28:46 -05:00
|
|
|
return NewClientDecorator(cfg, pluginRegistry, oAuthTokenService, tracer, cachingService, features, promRegisterer, pluginRegistry)
|
2022-12-01 12:08:36 -06:00
|
|
|
}
|
|
|
|
|
2023-04-12 11:30:33 -05:00
|
|
|
func NewClientDecorator(
|
2024-03-11 10:28:46 -05:00
|
|
|
cfg *setting.Cfg,
|
2023-04-12 11:30:33 -05:00
|
|
|
pluginRegistry registry.Service, oAuthTokenService oauthtoken.OAuthTokenService,
|
2024-04-04 11:22:31 -05:00
|
|
|
tracer tracing.Tracer, cachingService caching.CachingService, features featuremgmt.FeatureToggles,
|
2023-10-09 07:12:57 -05:00
|
|
|
promRegisterer prometheus.Registerer, registry registry.Service,
|
2023-04-12 11:30:33 -05:00
|
|
|
) (*client.Decorator, error) {
|
2024-03-11 10:28:46 -05:00
|
|
|
c := client.ProvideService(pluginRegistry)
|
2023-10-09 07:12:57 -05:00
|
|
|
middlewares := CreateMiddlewares(cfg, oAuthTokenService, tracer, cachingService, features, promRegisterer, registry)
|
2022-12-01 12:08:36 -06:00
|
|
|
return client.NewDecorator(c, middlewares...)
|
|
|
|
}
|
|
|
|
|
2024-04-04 11:22:31 -05:00
|
|
|
func CreateMiddlewares(cfg *setting.Cfg, oAuthTokenService oauthtoken.OAuthTokenService, tracer tracing.Tracer, cachingService caching.CachingService, features featuremgmt.FeatureToggles, promRegisterer prometheus.Registerer, registry registry.Service) []plugins.ClientMiddleware {
|
2024-02-21 05:57:40 -06:00
|
|
|
middlewares := []plugins.ClientMiddleware{
|
|
|
|
clientmiddleware.NewPluginRequestMetaMiddleware(),
|
2024-03-22 06:54:35 -05:00
|
|
|
clientmiddleware.NewTracingMiddleware(tracer),
|
|
|
|
clientmiddleware.NewMetricsMiddleware(promRegisterer, registry),
|
|
|
|
clientmiddleware.NewContextualLoggerMiddleware(),
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.PluginLogBackendRequests {
|
|
|
|
middlewares = append(middlewares, clientmiddleware.NewLoggerMiddleware(log.New("plugin.instrumentation")))
|
2023-10-31 07:42:39 -05:00
|
|
|
}
|
|
|
|
|
2022-12-01 12:08:36 -06:00
|
|
|
skipCookiesNames := []string{cfg.LoginCookieName}
|
2024-03-22 06:54:35 -05:00
|
|
|
|
2023-10-31 07:42:39 -05:00
|
|
|
middlewares = append(middlewares,
|
2022-12-22 04:15:00 -06:00
|
|
|
clientmiddleware.NewTracingHeaderMiddleware(),
|
2022-12-01 12:08:36 -06:00
|
|
|
clientmiddleware.NewClearAuthHeadersMiddleware(),
|
|
|
|
clientmiddleware.NewOAuthTokenMiddleware(oAuthTokenService),
|
|
|
|
clientmiddleware.NewCookiesMiddleware(skipCookiesNames),
|
2023-04-25 12:44:32 -05:00
|
|
|
clientmiddleware.NewResourceResponseMiddleware(),
|
2024-01-17 15:53:25 -06:00
|
|
|
clientmiddleware.NewCachingMiddlewareWithFeatureManager(cachingService, features),
|
2023-10-31 07:42:39 -05:00
|
|
|
)
|
2022-12-01 12:08:36 -06:00
|
|
|
|
2023-11-14 14:50:27 -06:00
|
|
|
if features.IsEnabledGlobally(featuremgmt.FlagIdForwarding) {
|
2023-10-02 02:14:10 -05:00
|
|
|
middlewares = append(middlewares, clientmiddleware.NewForwardIDMiddleware())
|
|
|
|
}
|
|
|
|
|
2022-12-15 08:28:25 -06:00
|
|
|
if cfg.SendUserHeader {
|
|
|
|
middlewares = append(middlewares, clientmiddleware.NewUserHeaderMiddleware())
|
|
|
|
}
|
|
|
|
|
2024-01-31 11:09:24 -06:00
|
|
|
if cfg.IPRangeACEnabled {
|
|
|
|
middlewares = append(middlewares, clientmiddleware.NewHostedGrafanaACHeaderMiddleware(cfg))
|
|
|
|
}
|
|
|
|
|
2022-12-21 06:25:58 -06:00
|
|
|
middlewares = append(middlewares, clientmiddleware.NewHTTPClientMiddleware())
|
|
|
|
|
2024-02-21 05:57:40 -06: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 07:42:39 -05:00
|
|
|
|
2022-12-01 12:08:36 -06:00
|
|
|
return middlewares
|
|
|
|
}
|