Alerting: Update alerting module + refactor (#111761)

* update alerting module
* replace compat with ones from alerting
* update type references Receiver and Integration to *Status
* update route in provisioning test that is invalid after recent change
* use right type for LINE ingtegration
This commit is contained in:
Yuri Tseretyan
2025-10-03 10:37:49 -04:00
committed by GitHub
parent cca9e0d55f
commit d0f79ee60d
25 changed files with 139 additions and 297 deletions
+12 -4
View File
@@ -13,6 +13,7 @@ import (
"github.com/go-openapi/strfmt"
"github.com/google/uuid"
alertingNotify "github.com/grafana/alerting/notify"
"github.com/grafana/alerting/notify/notifytest"
"github.com/grafana/alerting/receivers/schema"
"github.com/grafana/alerting/receivers/webex"
"github.com/grafana/grafana-plugin-sdk-go/data"
@@ -1270,7 +1271,7 @@ func CopyIntegrationWith(r Integration, mutators ...Mutator[Integration]) Integr
func IntegrationGen(mutators ...Mutator[Integration]) func() Integration {
return func() Integration {
name := util.GenerateShortUID()
randomIntegrationType, _ := randomMapKey(alertingNotify.AllKnownConfigsForTesting)
randomIntegrationType, _ := randomMapKey(notifytest.AllKnownV1ConfigsForTesting)
c := Integration{
UID: util.GenerateShortUID(),
@@ -1280,7 +1281,7 @@ func IntegrationGen(mutators ...Mutator[Integration]) func() Integration {
SecureSettings: make(map[string]string),
}
IntegrationMuts.WithValidConfig(schema.IntegrationType(randomIntegrationType))(&c)
IntegrationMuts.WithValidConfig(randomIntegrationType)(&c)
for _, mutator := range mutators {
mutator(&c)
@@ -1317,7 +1318,11 @@ func (n IntegrationMutators) WithName(name string) Mutator[Integration] {
func (n IntegrationMutators) WithValidConfig(integrationType schema.IntegrationType) Mutator[Integration] {
return func(c *Integration) {
// TODO add support for v0 integrations
config := alertingNotify.AllKnownConfigsForTesting[string(integrationType)].GetRawNotifierConfig(c.Name)
ncfg, ok := notifytest.AllKnownV1ConfigsForTesting[integrationType]
if !ok {
panic(fmt.Sprintf("unknown integration type: %s", integrationType))
}
config := ncfg.GetRawNotifierConfig(c.Name)
typeSchema, _ := alertingNotify.GetSchemaForIntegration(integrationType)
integrationConfig, _ := IntegrationConfigFromSchema(typeSchema, schema.V1)
c.Config = integrationConfig
@@ -1337,7 +1342,10 @@ func (n IntegrationMutators) WithValidConfig(integrationType schema.IntegrationT
func (n IntegrationMutators) WithInvalidConfig(integrationType schema.IntegrationType) Mutator[Integration] {
return func(c *Integration) {
typeSchema, _ := alertingNotify.GetSchemaForIntegration(integrationType)
typeSchema, ok := alertingNotify.GetSchemaForIntegration(integrationType)
if !ok {
panic(fmt.Sprintf("unknown integration type: %s", integrationType))
}
c.Config, _ = IntegrationConfigFromSchema(typeSchema, schema.V1)
c.Settings = map[string]interface{}{}
c.SecureSettings = map[string]string{}