mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -5,11 +5,11 @@ 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"
|
||||
skv "github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) AdminRotateDataEncryptionKeys(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminRotateDataEncryptionKeys(c *contextmodel.ReqContext) response.Response {
|
||||
if err := hs.SecretsService.RotateDataKeys(c.Req.Context()); err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to rotate data keys", err)
|
||||
}
|
||||
@@ -17,7 +17,7 @@ func (hs *HTTPServer) AdminRotateDataEncryptionKeys(c *models.ReqContext) respon
|
||||
return response.Respond(http.StatusNoContent, "")
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) AdminReEncryptEncryptionKeys(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminReEncryptEncryptionKeys(c *contextmodel.ReqContext) response.Response {
|
||||
if err := hs.SecretsService.ReEncryptDataKeys(c.Req.Context()); err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to re-encrypt data keys", err)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ func (hs *HTTPServer) AdminReEncryptEncryptionKeys(c *models.ReqContext) respons
|
||||
return response.Respond(http.StatusOK, "Data encryption keys re-encrypted successfully")
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) AdminReEncryptSecrets(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminReEncryptSecrets(c *contextmodel.ReqContext) response.Response {
|
||||
success, err := hs.secretsMigrator.ReEncryptSecrets(c.Req.Context())
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to re-encrypt secrets", err)
|
||||
@@ -38,7 +38,7 @@ func (hs *HTTPServer) AdminReEncryptSecrets(c *models.ReqContext) response.Respo
|
||||
return response.Respond(http.StatusOK, "Secrets re-encrypted successfully")
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) AdminRollbackSecrets(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminRollbackSecrets(c *contextmodel.ReqContext) response.Response {
|
||||
success, err := hs.secretsMigrator.RollBackSecrets(c.Req.Context())
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to rollback secrets", err)
|
||||
@@ -53,7 +53,7 @@ func (hs *HTTPServer) AdminRollbackSecrets(c *models.ReqContext) response.Respon
|
||||
|
||||
// To migrate to the plugin, it must be installed and configured
|
||||
// so as not to lose access to migrated secrets
|
||||
func (hs *HTTPServer) AdminMigrateSecretsToPlugin(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminMigrateSecretsToPlugin(c *contextmodel.ReqContext) response.Response {
|
||||
if skv.EvaluateRemoteSecretsPlugin(c.Req.Context(), hs.secretsPluginManager, hs.Cfg) != nil {
|
||||
hs.log.Warn("Received secrets plugin migration request while plugin is not available")
|
||||
return response.Respond(http.StatusBadRequest, "Secrets plugin is not available")
|
||||
@@ -68,7 +68,7 @@ func (hs *HTTPServer) AdminMigrateSecretsToPlugin(c *models.ReqContext) response
|
||||
|
||||
// To migrate from the plugin, it must be installed only
|
||||
// as it is possible the user disabled it and then wants to migrate
|
||||
func (hs *HTTPServer) AdminMigrateSecretsFromPlugin(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminMigrateSecretsFromPlugin(c *contextmodel.ReqContext) response.Response {
|
||||
if hs.secretsPluginManager.SecretsManager(c.Req.Context()) == nil {
|
||||
hs.log.Warn("Received secrets plugin migration request while plugin is not installed")
|
||||
return response.Respond(http.StatusBadRequest, "Secrets plugin is not installed")
|
||||
@@ -81,7 +81,7 @@ func (hs *HTTPServer) AdminMigrateSecretsFromPlugin(c *models.ReqContext) respon
|
||||
return response.Respond(http.StatusOK, "Secret migration from plugin triggered successfully")
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) AdminDeleteAllSecretsManagerPluginSecrets(c *models.ReqContext) response.Response {
|
||||
func (hs *HTTPServer) AdminDeleteAllSecretsManagerPluginSecrets(c *contextmodel.ReqContext) response.Response {
|
||||
if hs.secretsPluginManager.SecretsManager(c.Req.Context()) == nil {
|
||||
hs.log.Warn("Received secrets plugin deletion request while plugin is not installed")
|
||||
return response.Respond(http.StatusBadRequest, "Secrets plugin is not installed")
|
||||
|
||||
Reference in New Issue
Block a user