Alerting: Code-gen parsing of URL parameters and fix related bugs (#50731)

* Extend template and generate

* Generate and fix up alertmanager endpoints

* Prometheus routes

* fix up Testing endpoints

* touch up ruler API

* Update provisioning and fix 500

* Drop dead code

* Remove more dead code

* Resolve merge conflicts
This commit is contained in:
Alexander Weaver
2022-06-23 15:13:39 -05:00
committed by GitHub
parent 80f6560c9c
commit 0d9389e1f4
21 changed files with 262 additions and 262 deletions

View File

@@ -20,7 +20,6 @@ import (
"github.com/grafana/grafana/pkg/services/ngalert/eval"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/web"
)
type TestingApiSrv struct {
@@ -69,13 +68,12 @@ func (srv TestingApiSrv) RouteTestGrafanaRuleConfig(c *models.ReqContext, body a
})
}
func (srv TestingApiSrv) RouteTestRuleConfig(c *models.ReqContext, body apimodels.TestRulePayload) response.Response {
func (srv TestingApiSrv) RouteTestRuleConfig(c *models.ReqContext, body apimodels.TestRulePayload, datasourceUID string) response.Response {
if body.Type() != apimodels.LoTexRulerBackend {
return ErrResp(http.StatusBadRequest, errors.New("unexpected payload"), "")
}
var path string
datasourceUID := web.Params(c.Req)[":DatasourceUID"]
ds, err := srv.DatasourceCache.GetDatasourceByUID(context.Background(), datasourceUID, c.SignedInUser, c.SkipCache)
if err != nil {
return ErrResp(http.StatusInternalServerError, err, "failed to get datasource")