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:
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/appcontext"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
@@ -27,16 +27,16 @@ import (
|
||||
|
||||
type ExportService interface {
|
||||
// List folder contents
|
||||
HandleGetStatus(c *models.ReqContext) response.Response
|
||||
HandleGetStatus(c *contextmodel.ReqContext) response.Response
|
||||
|
||||
// List Get Options
|
||||
HandleGetOptions(c *models.ReqContext) response.Response
|
||||
HandleGetOptions(c *contextmodel.ReqContext) response.Response
|
||||
|
||||
// Read raw file contents out of the store
|
||||
HandleRequestExport(c *models.ReqContext) response.Response
|
||||
HandleRequestExport(c *contextmodel.ReqContext) response.Response
|
||||
|
||||
// Cancel any running export
|
||||
HandleRequestStop(c *models.ReqContext) response.Response
|
||||
HandleRequestStop(c *contextmodel.ReqContext) response.Response
|
||||
}
|
||||
|
||||
var exporters = []Exporter{
|
||||
@@ -186,21 +186,21 @@ func ProvideService(db db.DB, features featuremgmt.FeatureToggles, gl *live.Graf
|
||||
}
|
||||
}
|
||||
|
||||
func (ex *StandardExport) HandleGetOptions(c *models.ReqContext) response.Response {
|
||||
func (ex *StandardExport) HandleGetOptions(c *contextmodel.ReqContext) response.Response {
|
||||
info := map[string]interface{}{
|
||||
"exporters": exporters,
|
||||
}
|
||||
return response.JSON(http.StatusOK, info)
|
||||
}
|
||||
|
||||
func (ex *StandardExport) HandleGetStatus(c *models.ReqContext) response.Response {
|
||||
func (ex *StandardExport) HandleGetStatus(c *contextmodel.ReqContext) response.Response {
|
||||
ex.mutex.Lock()
|
||||
defer ex.mutex.Unlock()
|
||||
|
||||
return response.JSON(http.StatusOK, ex.exportJob.getStatus())
|
||||
}
|
||||
|
||||
func (ex *StandardExport) HandleRequestStop(c *models.ReqContext) response.Response {
|
||||
func (ex *StandardExport) HandleRequestStop(c *contextmodel.ReqContext) response.Response {
|
||||
ex.mutex.Lock()
|
||||
defer ex.mutex.Unlock()
|
||||
|
||||
@@ -209,7 +209,7 @@ func (ex *StandardExport) HandleRequestStop(c *models.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, ex.exportJob.getStatus())
|
||||
}
|
||||
|
||||
func (ex *StandardExport) HandleRequestExport(c *models.ReqContext) response.Response {
|
||||
func (ex *StandardExport) HandleRequestExport(c *contextmodel.ReqContext) response.Response {
|
||||
var cfg ExportConfig
|
||||
err := json.NewDecoder(c.Req.Body).Decode(&cfg)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,25 +4,25 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
)
|
||||
|
||||
var _ ExportService = new(StubExport)
|
||||
|
||||
type StubExport struct{}
|
||||
|
||||
func (ex *StubExport) HandleGetStatus(c *models.ReqContext) response.Response {
|
||||
func (ex *StubExport) HandleGetStatus(c *contextmodel.ReqContext) response.Response {
|
||||
return response.Error(http.StatusForbidden, "feature not enabled", nil)
|
||||
}
|
||||
|
||||
func (ex *StubExport) HandleGetOptions(c *models.ReqContext) response.Response {
|
||||
func (ex *StubExport) HandleGetOptions(c *contextmodel.ReqContext) response.Response {
|
||||
return response.Error(http.StatusForbidden, "feature not enabled", nil)
|
||||
}
|
||||
|
||||
func (ex *StubExport) HandleRequestExport(c *models.ReqContext) response.Response {
|
||||
func (ex *StubExport) HandleRequestExport(c *contextmodel.ReqContext) response.Response {
|
||||
return response.Error(http.StatusForbidden, "feature not enabled", nil)
|
||||
}
|
||||
|
||||
func (ex *StubExport) HandleRequestStop(c *models.ReqContext) response.Response {
|
||||
func (ex *StubExport) HandleRequestStop(c *contextmodel.ReqContext) response.Response {
|
||||
return response.Error(http.StatusForbidden, "feature not enabled", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user