Files
grafana/pkg/services/ngalert/notifier/compat.go
T
Yuri Tseretyan d0f79ee60d 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
2025-10-03 10:37:49 -04:00

34 lines
817 B
Go

package notifier
import (
alertingNotify "github.com/grafana/alerting/notify"
"github.com/grafana/grafana/pkg/services/ngalert/models"
)
// Silence-specific compat functions to convert between grafana/alerting and model types.
func GettableSilenceToSilence(s alertingNotify.GettableSilence) *models.Silence {
sil := models.Silence(s)
return &sil
}
func GettableSilencesToSilences(silences alertingNotify.GettableSilences) []*models.Silence {
res := make([]*models.Silence, 0, len(silences))
for _, sil := range silences {
res = append(res, GettableSilenceToSilence(*sil))
}
return res
}
func SilenceToPostableSilence(s models.Silence) *alertingNotify.PostableSilence {
var id string
if s.ID != nil {
id = *s.ID
}
return &alertingNotify.PostableSilence{
ID: id,
Silence: s.Silence,
}
}