grafana/pkg/services/ngalert/notifier/status.go
Matthew Jacobson 2e8c514cfd
Alerting: Stop persisting user-defined templates to disk (#83456)
Updates Grafana Alertmanager to work with new interface from grafana/alerting#161. This change stops passing user-defined templates to the Grafana Alertmanager by persisting them to disk and instead passes them by string.
2024-03-04 20:12:49 +02:00

23 lines
716 B
Go

package notifier
import (
"encoding/json"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
)
// TODO: We no longer do apimodels at this layer, move it to the API.
func (am *alertmanager) GetStatus() apimodels.GettableStatus {
config := &apimodels.PostableUserConfig{}
status := am.Base.GetStatus() // TODO: This should return a GettableStatus, for now it returns PostableUserConfig.
if status == nil {
return *apimodels.NewGettableStatus(&config.AlertmanagerConfig)
}
if err := json.Unmarshal(status, config); err != nil {
am.logger.Error("Unable to unmarshall alertmanager config", "Err", err)
}
return *apimodels.NewGettableStatus(&config.AlertmanagerConfig)
}