Chore: Move ReqContext to contexthandler service (#62102)

* Chore: Move ReqContext to contexthandler service

* Rename package to contextmodel

* Generate ngalert files

* Remove unused imports
This commit is contained in:
idafurjes
2023-01-27 08:50:36 +01:00
committed by GitHub
parent 8379a29b53
commit 6c5a573772
180 changed files with 1208 additions and 1182 deletions
@@ -2,7 +2,7 @@ package api
import (
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/models"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/datasources"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
)
@@ -22,7 +22,7 @@ func NewForkingProm(datasourceCache datasources.CacheService, proxy *LotexProm,
}
}
func (f *PrometheusApiHandler) handleRouteGetAlertStatuses(ctx *models.ReqContext, dsUID string) response.Response {
func (f *PrometheusApiHandler) handleRouteGetAlertStatuses(ctx *contextmodel.ReqContext, dsUID string) response.Response {
t, err := f.getService(ctx)
if err != nil {
return errorToResponse(err)
@@ -30,7 +30,7 @@ func (f *PrometheusApiHandler) handleRouteGetAlertStatuses(ctx *models.ReqContex
return t.RouteGetAlertStatuses(ctx)
}
func (f *PrometheusApiHandler) handleRouteGetRuleStatuses(ctx *models.ReqContext, dsUID string) response.Response {
func (f *PrometheusApiHandler) handleRouteGetRuleStatuses(ctx *contextmodel.ReqContext, dsUID string) response.Response {
t, err := f.getService(ctx)
if err != nil {
return errorToResponse(err)
@@ -38,15 +38,15 @@ func (f *PrometheusApiHandler) handleRouteGetRuleStatuses(ctx *models.ReqContext
return t.RouteGetRuleStatuses(ctx)
}
func (f *PrometheusApiHandler) handleRouteGetGrafanaAlertStatuses(ctx *models.ReqContext) response.Response {
func (f *PrometheusApiHandler) handleRouteGetGrafanaAlertStatuses(ctx *contextmodel.ReqContext) response.Response {
return f.GrafanaSvc.RouteGetAlertStatuses(ctx)
}
func (f *PrometheusApiHandler) handleRouteGetGrafanaRuleStatuses(ctx *models.ReqContext) response.Response {
func (f *PrometheusApiHandler) handleRouteGetGrafanaRuleStatuses(ctx *contextmodel.ReqContext) response.Response {
return f.GrafanaSvc.RouteGetRuleStatuses(ctx)
}
func (f *PrometheusApiHandler) getService(ctx *models.ReqContext) (*LotexProm, error) {
func (f *PrometheusApiHandler) getService(ctx *contextmodel.ReqContext) (*LotexProm, error) {
_, err := getDatasourceByUID(ctx, f.DatasourceCache, apimodels.LoTexRulerBackend)
if err != nil {
return nil, err