Chore: use any rather than interface{} (#74066)
This commit is contained in:
+2
-2
@@ -695,7 +695,7 @@ func (hs *HTTPServer) PauseAlert(legacyAlertingEnabled *bool) func(c *contextmod
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "alertId is invalid", err)
|
||||
}
|
||||
result := make(map[string]interface{})
|
||||
result := make(map[string]any)
|
||||
result["alertId"] = alertID
|
||||
|
||||
query := alertmodels.GetAlertByIdQuery{ID: alertID}
|
||||
@@ -789,7 +789,7 @@ func (hs *HTTPServer) PauseAllAlerts(legacyAlertingEnabled *bool) func(c *contex
|
||||
pausedState = "paused"
|
||||
}
|
||||
|
||||
result := map[string]interface{}{
|
||||
result := map[string]any{
|
||||
"state": resp,
|
||||
"message": "alerts " + pausedState,
|
||||
"alertsAffected": updateCmd.ResultCount,
|
||||
|
||||
@@ -200,7 +200,7 @@ func (hs *HTTPServer) PostGraphiteAnnotation(c *contextmodel.ReqContext) respons
|
||||
} else {
|
||||
tagsArray = []string{}
|
||||
}
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for _, t := range tags {
|
||||
if tagStr, ok := t.(string); ok {
|
||||
tagsArray = append(tagsArray, tagStr)
|
||||
|
||||
@@ -243,7 +243,7 @@ func setupSimpleHTTPServer(features *featuremgmt.FeatureManager) *HTTPServer {
|
||||
}
|
||||
}
|
||||
|
||||
func mockRequestBody(v interface{}) io.ReadCloser {
|
||||
func mockRequestBody(v any) io.ReadCloser {
|
||||
b, _ := json.Marshal(v)
|
||||
return io.NopCloser(bytes.NewReader(b))
|
||||
}
|
||||
|
||||
@@ -634,10 +634,10 @@ func (hs *HTTPServer) addGettingStartedPanelToHomeDashboard(c *contextmodel.ReqC
|
||||
|
||||
panels := dash.Get("panels").MustArray()
|
||||
|
||||
newpanel := simplejson.NewFromAny(map[string]interface{}{
|
||||
newpanel := simplejson.NewFromAny(map[string]any{
|
||||
"type": "gettingstarted",
|
||||
"id": 123123,
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 24,
|
||||
|
||||
@@ -51,7 +51,7 @@ type CreateExternalSnapshotResponse struct {
|
||||
|
||||
func createExternalDashboardSnapshot(cmd dashboardsnapshots.CreateDashboardSnapshotCommand, externalSnapshotUrl string) (*CreateExternalSnapshotResponse, error) {
|
||||
var createSnapshotResponse CreateExternalSnapshotResponse
|
||||
message := map[string]interface{}{
|
||||
message := map[string]any{
|
||||
"name": cmd.Name,
|
||||
"expires": cmd.Expires,
|
||||
"dashboard": cmd.Dashboard,
|
||||
@@ -259,7 +259,7 @@ func deleteExternalDashboardSnapshot(externalUrl string) error {
|
||||
// Gracefully ignore "snapshot not found" errors as they could have already
|
||||
// been removed either via the cleanup script or by request.
|
||||
if resp.StatusCode == 500 {
|
||||
var respJson map[string]interface{}
|
||||
var respJson map[string]any
|
||||
if err := json.NewDecoder(resp.Body).Decode(&respJson); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: 1,
|
||||
UserID: 5,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash",
|
||||
}),
|
||||
Overwrite: true,
|
||||
@@ -429,7 +429,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: 1,
|
||||
UserID: 5,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash",
|
||||
}),
|
||||
Overwrite: true,
|
||||
@@ -462,7 +462,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: 1,
|
||||
UserID: 5,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash",
|
||||
}),
|
||||
Overwrite: true,
|
||||
@@ -510,7 +510,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: 1,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "",
|
||||
}),
|
||||
}
|
||||
@@ -588,14 +588,14 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
{
|
||||
DashboardID: 1,
|
||||
Version: 1,
|
||||
Data: simplejson.NewFromAny(map[string]interface{}{
|
||||
Data: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash1",
|
||||
}),
|
||||
},
|
||||
{
|
||||
DashboardID: 2,
|
||||
Version: 2,
|
||||
Data: simplejson.NewFromAny(map[string]interface{}{
|
||||
Data: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash2",
|
||||
}),
|
||||
},
|
||||
@@ -1142,7 +1142,7 @@ func (m *mockLibraryPanelService) ConnectLibraryPanelsForDashboard(c context.Con
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockLibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser *user.SignedInUser, libraryPanels *simplejson.Json, panels []interface{}, folderID int64) error {
|
||||
func (m *mockLibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser *user.SignedInUser, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ type DatasourceProxyRouteParam struct {
|
||||
type DatasourceProxyPOSTcallsParams struct {
|
||||
// in:body
|
||||
// required:true
|
||||
DatasourceProxyParam interface{}
|
||||
DatasourceProxyParam any
|
||||
// in:path
|
||||
// required:true
|
||||
DatasourceProxyRoute string `json:"datasource_proxy_route"`
|
||||
@@ -166,7 +166,7 @@ type DatasourceProxyPOSTcallsParams struct {
|
||||
type DatasourceProxyPOSTByUIDcallsParams struct {
|
||||
// in:body
|
||||
// required:true
|
||||
DatasourceProxyParam interface{}
|
||||
DatasourceProxyParam any
|
||||
// in:path
|
||||
// required:true
|
||||
DatasourceProxyRoute string `json:"datasource_proxy_route"`
|
||||
|
||||
@@ -839,14 +839,14 @@ func (hs *HTTPServer) checkDatasourceHealth(c *contextmodel.ReqContext, ds *data
|
||||
return translatePluginRequestErrorToAPIError(err)
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
payload := map[string]any{
|
||||
"status": resp.Status.String(),
|
||||
"message": resp.Message,
|
||||
}
|
||||
|
||||
// Unmarshal JSONDetails if it's not empty.
|
||||
if len(resp.JSONDetails) > 0 {
|
||||
var jsonDetails map[string]interface{}
|
||||
var jsonDetails map[string]any
|
||||
err = json.Unmarshal(resp.JSONDetails, &jsonDetails)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to unmarshal detailed response from backend plugin", err)
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestDataSourcesProxy_userLoggedIn(t *testing.T) {
|
||||
sc.handlerFunc = hs.GetDataSources
|
||||
sc.fakeReq("GET", "/api/datasources").exec()
|
||||
|
||||
respJSON := []map[string]interface{}{}
|
||||
respJSON := []map[string]any{}
|
||||
err := json.NewDecoder(sc.resp.Body).Decode(&respJSON)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ type AlertTestResult struct {
|
||||
}
|
||||
|
||||
type AlertTestResultLog struct {
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
type EvalMatch struct {
|
||||
|
||||
@@ -40,8 +40,8 @@ type MassDeleteAnnotationsCmd struct {
|
||||
}
|
||||
|
||||
type PostGraphiteAnnotationsCmd struct {
|
||||
When int64 `json:"when"`
|
||||
What string `json:"what"`
|
||||
Data string `json:"data"`
|
||||
Tags interface{} `json:"tags"`
|
||||
When int64 `json:"when"`
|
||||
What string `json:"what"`
|
||||
Data string `json:"data"`
|
||||
Tags any `json:"tags"`
|
||||
}
|
||||
|
||||
@@ -209,13 +209,13 @@ type FrontendSettingsDTO struct {
|
||||
Reporting FrontendSettingsReportingDTO `json:"reporting"`
|
||||
UnifiedAlertingEnabled bool `json:"unifiedAlertingEnabled"`
|
||||
UnifiedAlerting FrontendSettingsUnifiedAlertingDTO `json:"unifiedAlerting"`
|
||||
Oauth map[string]interface{} `json:"oauth"`
|
||||
Oauth map[string]any `json:"oauth"`
|
||||
SamlEnabled bool `json:"samlEnabled"`
|
||||
SamlName string `json:"samlName"`
|
||||
TokenExpirationDayLimit int `json:"tokenExpirationDayLimit"`
|
||||
|
||||
GeomapDefaultBaseLayerConfig *map[string]interface{} `json:"geomapDefaultBaseLayerConfig,omitempty"`
|
||||
GeomapDisableCustomBaseLayer bool `json:"geomapDisableCustomBaseLayer"`
|
||||
GeomapDefaultBaseLayerConfig *map[string]any `json:"geomapDefaultBaseLayerConfig,omitempty"`
|
||||
GeomapDisableCustomBaseLayer bool `json:"geomapDisableCustomBaseLayer"`
|
||||
|
||||
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
|
||||
|
||||
|
||||
+10
-10
@@ -21,20 +21,20 @@ func TestGetUniqueDatasourceTypes(t *testing.T) {
|
||||
desc: "can get unique datasource names",
|
||||
result: []string{"mysql", "prometheus"},
|
||||
queries: []*simplejson.Json{
|
||||
simplejson.NewFromAny(map[string]interface{}{
|
||||
"datasource": map[string]interface{}{
|
||||
simplejson.NewFromAny(map[string]any{
|
||||
"datasource": map[string]any{
|
||||
"type": "prometheus",
|
||||
"uid": "uid1",
|
||||
},
|
||||
}),
|
||||
simplejson.NewFromAny(map[string]interface{}{
|
||||
"datasource": map[string]interface{}{
|
||||
simplejson.NewFromAny(map[string]any{
|
||||
"datasource": map[string]any{
|
||||
"type": "prometheus",
|
||||
"uid": "uid2",
|
||||
},
|
||||
}),
|
||||
simplejson.NewFromAny(map[string]interface{}{
|
||||
"datasource": map[string]interface{}{
|
||||
simplejson.NewFromAny(map[string]any{
|
||||
"datasource": map[string]any{
|
||||
"type": "mysql",
|
||||
"uid": "uid3",
|
||||
},
|
||||
@@ -45,13 +45,13 @@ func TestGetUniqueDatasourceTypes(t *testing.T) {
|
||||
desc: "returns empty slice when datasources have no type property",
|
||||
result: []string{},
|
||||
queries: []*simplejson.Json{
|
||||
simplejson.NewFromAny(map[string]interface{}{
|
||||
"datasource": map[string]interface{}{
|
||||
simplejson.NewFromAny(map[string]any{
|
||||
"datasource": map[string]any{
|
||||
"uid": "uid1",
|
||||
},
|
||||
}),
|
||||
simplejson.NewFromAny(map[string]interface{}{
|
||||
"datasource": map[string]interface{}{
|
||||
simplejson.NewFromAny(map[string]any{
|
||||
"datasource": map[string]any{
|
||||
"uid": "uid3",
|
||||
},
|
||||
}),
|
||||
|
||||
+13
-13
@@ -6,19 +6,19 @@ import (
|
||||
)
|
||||
|
||||
type PluginSetting struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Id string `json:"id"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Pinned bool `json:"pinned"`
|
||||
Module string `json:"module"`
|
||||
BaseUrl string `json:"baseUrl"`
|
||||
Info plugins.Info `json:"info"`
|
||||
Includes []*plugins.Includes `json:"includes"`
|
||||
Dependencies plugins.Dependencies `json:"dependencies"`
|
||||
JsonData map[string]interface{} `json:"jsonData"`
|
||||
SecureJsonFields map[string]bool `json:"secureJsonFields"`
|
||||
DefaultNavUrl string `json:"defaultNavUrl"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Id string `json:"id"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Pinned bool `json:"pinned"`
|
||||
Module string `json:"module"`
|
||||
BaseUrl string `json:"baseUrl"`
|
||||
Info plugins.Info `json:"info"`
|
||||
Includes []*plugins.Includes `json:"includes"`
|
||||
Dependencies plugins.Dependencies `json:"dependencies"`
|
||||
JsonData map[string]any `json:"jsonData"`
|
||||
SecureJsonFields map[string]bool `json:"secureJsonFields"`
|
||||
DefaultNavUrl string `json:"defaultNavUrl"`
|
||||
|
||||
LatestVersion string `json:"latestVersion"`
|
||||
HasUpdate bool `json:"hasUpdate"`
|
||||
|
||||
@@ -351,12 +351,12 @@ func findResult(t *testing.T, result []featuremgmt.FeatureToggleDTO, name string
|
||||
return featuremgmt.FeatureToggleDTO{}, false
|
||||
}
|
||||
|
||||
func readBody(t *testing.T, rc io.ReadCloser) map[string]interface{} {
|
||||
func readBody(t *testing.T, rc io.ReadCloser) map[string]any {
|
||||
t.Helper()
|
||||
|
||||
b, err := io.ReadAll(rc)
|
||||
require.NoError(t, err)
|
||||
payload := map[string]interface{}{}
|
||||
payload := map[string]any{}
|
||||
require.NoError(t, json.Unmarshal(b, &payload))
|
||||
return payload
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ func addFolder(orgID int64, id int64, uid string, parentUID *string) (*f, *dashb
|
||||
UID: uid,
|
||||
Version: 1,
|
||||
Title: title,
|
||||
Data: simplejson.NewFromAny(map[string]interface{}{"schemaVersion": 17, "title": title, "uid": uid, "version": 1}),
|
||||
Data: simplejson.NewFromAny(map[string]any{"schemaVersion": 17, "title": title, "uid": uid, "version": 1}),
|
||||
IsFolder: true,
|
||||
Created: now,
|
||||
Updated: now,
|
||||
|
||||
@@ -27,13 +27,13 @@ type SourceMapReadRecord struct {
|
||||
path string
|
||||
}
|
||||
|
||||
type logScenarioFunc func(c *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord)
|
||||
type logScenarioFunc func(c *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord)
|
||||
|
||||
func logGrafanaJavascriptAgentEventScenario(t *testing.T, desc string, event frontendlogging.FrontendGrafanaJavascriptAgentEvent, fn logScenarioFunc) {
|
||||
t.Run(desc, func(t *testing.T) {
|
||||
var logcontent = make(map[string]interface{})
|
||||
var logcontent = make(map[string]any)
|
||||
logcontent["logger"] = "frontend"
|
||||
newfrontendLogger := log.Logger(log.LoggerFunc(func(keyvals ...interface{}) error {
|
||||
newfrontendLogger := log.Logger(log.LoggerFunc(func(keyvals ...any) error {
|
||||
for i := 0; i < len(keyvals); i += 2 {
|
||||
logcontent[keyvals[i].(string)] = keyvals[i+1]
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func TestFrontendLoggingEndpointGrafanaJavascriptAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
logGrafanaJavascriptAgentEventScenario(t, "Should log received error event", errorEvent,
|
||||
func(sc *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord) {
|
||||
func(sc *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord) {
|
||||
assert.Equal(t, http.StatusAccepted, sc.resp.Code)
|
||||
assertContextContains(t, logs, "logger", "frontend")
|
||||
assertContextContains(t, logs, "page_url", errorEvent.Meta.Page.URL)
|
||||
@@ -161,7 +161,7 @@ func TestFrontendLoggingEndpointGrafanaJavascriptAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
logGrafanaJavascriptAgentEventScenario(t, "Should log received log event", logEvent,
|
||||
func(sc *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord) {
|
||||
func(sc *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord) {
|
||||
assert.Equal(t, http.StatusAccepted, sc.resp.Code)
|
||||
assert.Len(t, logs, 11)
|
||||
assertContextContains(t, logs, "logger", "frontend")
|
||||
@@ -186,7 +186,7 @@ func TestFrontendLoggingEndpointGrafanaJavascriptAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
logGrafanaJavascriptAgentEventScenario(t, "Should log received log context", logEventWithContext,
|
||||
func(sc *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord) {
|
||||
func(sc *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord) {
|
||||
assert.Equal(t, http.StatusAccepted, sc.resp.Code)
|
||||
assertContextContains(t, logs, "context_one", "two")
|
||||
assertContextContains(t, logs, "context_bar", "baz")
|
||||
@@ -249,7 +249,7 @@ func TestFrontendLoggingEndpointGrafanaJavascriptAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
logGrafanaJavascriptAgentEventScenario(t, "Should load sourcemap and transform stacktrace line when possible", errorEventForSourceMapping,
|
||||
func(sc *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord) {
|
||||
func(sc *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord) {
|
||||
assert.Equal(t, http.StatusAccepted, sc.resp.Code)
|
||||
assertContextContains(t, logs, "stacktrace", `UserError: Please replace user and try again
|
||||
at ? (core|webpack:///./some_source.ts:2:2)
|
||||
@@ -285,14 +285,14 @@ func TestFrontendLoggingEndpointGrafanaJavascriptAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
logGrafanaJavascriptAgentEventScenario(t, "Should log web vitals as context", logWebVitals,
|
||||
func(sc *scenarioContext, logs map[string]interface{}, sourceMapReads []SourceMapReadRecord) {
|
||||
func(sc *scenarioContext, logs map[string]any, sourceMapReads []SourceMapReadRecord) {
|
||||
assert.Equal(t, http.StatusAccepted, sc.resp.Code)
|
||||
assertContextContains(t, logs, "CLS", float64(1))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func assertContextContains(t *testing.T, logRecord map[string]interface{}, label string, value interface{}) {
|
||||
func assertContextContains(t *testing.T, logRecord map[string]any, label string, value any) {
|
||||
assert.Contains(t, logRecord, label)
|
||||
assert.Equal(t, value, logRecord[label])
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CtxVector []interface{}
|
||||
type CtxVector []any
|
||||
|
||||
type FrontendGrafanaJavascriptAgentEvent struct {
|
||||
Exceptions []Exception `json:"exceptions,omitempty"`
|
||||
@@ -15,14 +15,14 @@ type FrontendGrafanaJavascriptAgentEvent struct {
|
||||
}
|
||||
|
||||
// KeyValToInterfaceMap converts KeyVal to map[string]interface
|
||||
func KeyValToInterfaceMap(kv *KeyVal) map[string]interface{} {
|
||||
retv := make(map[string]interface{})
|
||||
func KeyValToInterfaceMap(kv *KeyVal) map[string]any {
|
||||
retv := make(map[string]any)
|
||||
for el := kv.Oldest(); el != nil; el = el.Next() {
|
||||
retv[fmt.Sprint(el.Key)] = el.Value
|
||||
}
|
||||
return retv
|
||||
}
|
||||
func (event *FrontendGrafanaJavascriptAgentEvent) AddMetaToContext(ctx CtxVector) []interface{} {
|
||||
func (event *FrontendGrafanaJavascriptAgentEvent) AddMetaToContext(ctx CtxVector) []any {
|
||||
for k, v := range KeyValToInterfaceMap(event.Meta.KeyVal()) {
|
||||
ctx = append(ctx, k, v)
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlug
|
||||
dsDTO.AngularDetected = plugin.AngularDetected
|
||||
|
||||
if ds.JsonData == nil {
|
||||
dsDTO.JSONData = make(map[string]interface{})
|
||||
dsDTO.JSONData = make(map[string]any)
|
||||
} else {
|
||||
dsDTO.JSONData = ds.JsonData.MustMap()
|
||||
}
|
||||
@@ -406,7 +406,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlug
|
||||
dto := plugins.DataSourceDTO{
|
||||
Type: string(ds.Type),
|
||||
Name: ds.Name,
|
||||
JSONData: make(map[string]interface{}),
|
||||
JSONData: make(map[string]any),
|
||||
PluginMeta: &plugins.PluginMetaDTO{
|
||||
JSONData: ds.JSONData,
|
||||
Signature: ds.Signature,
|
||||
@@ -611,8 +611,8 @@ func (hs *HTTPServer) pluginSettings(ctx context.Context, orgID int64) (map[stri
|
||||
return pluginSettings, nil
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) getEnabledOAuthProviders() map[string]interface{} {
|
||||
providers := make(map[string]interface{})
|
||||
func (hs *HTTPServer) getEnabledOAuthProviders() map[string]any {
|
||||
providers := make(map[string]any)
|
||||
for key, oauth := range hs.SocialService.GetOAuthInfoProviders() {
|
||||
providers[key] = map[string]string{
|
||||
"name": oauth.Name,
|
||||
|
||||
+2
-2
@@ -315,12 +315,12 @@ func (hs *HTTPServer) trySetEncryptedCookie(ctx *contextmodel.ReqContext, cookie
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) redirectWithError(c *contextmodel.ReqContext, err error, v ...interface{}) {
|
||||
func (hs *HTTPServer) redirectWithError(c *contextmodel.ReqContext, err error, v ...any) {
|
||||
c.Logger.Warn(err.Error(), v...)
|
||||
c.Redirect(hs.redirectURLWithErrorCookie(c, err))
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) RedirectResponseWithError(c *contextmodel.ReqContext, err error, v ...interface{}) *response.RedirectResponse {
|
||||
func (hs *HTTPServer) RedirectResponseWithError(c *contextmodel.ReqContext, err error, v ...any) *response.RedirectResponse {
|
||||
c.Logger.Error(err.Error(), v...)
|
||||
location := hs.redirectURLWithErrorCookie(c, err)
|
||||
return response.Redirect(location)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func openapi3(c *contextmodel.ReqContext) {
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Nonce": c.RequestNonce,
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ func (hs *HTTPServer) AddOrgInvite(c *contextmodel.ReqContext) response.Response
|
||||
emailCmd := notifications.SendEmailCommand{
|
||||
To: []string{inviteDto.LoginOrEmail},
|
||||
Template: "new_user_invite",
|
||||
Data: map[string]interface{}{
|
||||
Data: map[string]any{
|
||||
"Name": util.StringsFallback2(cmd.Name, cmd.Email),
|
||||
"OrgName": c.SignedInUser.GetOrgName(),
|
||||
"Email": c.SignedInUser.GetEmail(),
|
||||
@@ -172,7 +172,7 @@ func (hs *HTTPServer) inviteExistingUserToOrg(c *contextmodel.ReqContext, user *
|
||||
emailCmd := notifications.SendEmailCommand{
|
||||
To: []string{user.Email},
|
||||
Template: "invited_to_org",
|
||||
Data: map[string]interface{}{
|
||||
Data: map[string]any{
|
||||
"Name": user.NameOrFallback(),
|
||||
"OrgName": c.SignedInUser.GetOrgName(),
|
||||
"InvitedBy": c.SignedInUser.GetDisplayName(),
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestCallResource(t *testing.T) {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var body = make(map[string]interface{})
|
||||
var body = make(map[string]any)
|
||||
err = json.Unmarshal(b, &body)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
type DSInfo struct {
|
||||
ID int64
|
||||
Updated time.Time
|
||||
JSONData map[string]interface{}
|
||||
JSONData map[string]any
|
||||
DecryptedSecureJSONData map[string]string
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestApplyRoute_interpolateAuthParams(t *testing.T) {
|
||||
}
|
||||
|
||||
validData := templateData{
|
||||
JsonData: map[string]interface{}{
|
||||
JsonData: map[string]any{
|
||||
"clientEmail": "test@test.com",
|
||||
"tokenUri": "login.url.com/token",
|
||||
"tenantId": "f09c86ac",
|
||||
@@ -34,7 +34,7 @@ func TestApplyRoute_interpolateAuthParams(t *testing.T) {
|
||||
}
|
||||
|
||||
emptyData := templateData{
|
||||
JsonData: map[string]interface{}{},
|
||||
JsonData: map[string]any{},
|
||||
SecureJsonData: map[string]string{},
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ func (proxy *DataSourceProxy) director(req *http.Request) {
|
||||
proxyutil.ClearCookieHeader(req, proxy.ds.AllowedCookies(), []string{proxy.cfg.LoginCookieName})
|
||||
req.Header.Set("User-Agent", proxy.cfg.DataProxyUserAgent)
|
||||
|
||||
jsonData := make(map[string]interface{})
|
||||
jsonData := make(map[string]any)
|
||||
if proxy.ds.JsonData != nil {
|
||||
jsonData, err = proxy.ds.JsonData.Map()
|
||||
if err != nil {
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
ds := &datasources.DataSource{
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"clientId": "asd",
|
||||
"dynamicUrl": "https://dynamic.grafana.com",
|
||||
"queryParam": "apiKey",
|
||||
@@ -277,7 +277,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
ds := &datasources.DataSource{
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"clientId": "asd",
|
||||
"tenantId": "mytenantId",
|
||||
}),
|
||||
@@ -517,7 +517,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
ds := &datasources.DataSource{
|
||||
Type: "custom-datasource",
|
||||
URL: "http://host/root/",
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"oauthPassThru": true,
|
||||
}),
|
||||
}
|
||||
@@ -535,7 +535,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
TokenType: "Bearer",
|
||||
Expiry: time.Now().AddDate(0, 0, 1),
|
||||
}
|
||||
extra := map[string]interface{}{
|
||||
extra := map[string]any{
|
||||
"id_token": "testidtoken",
|
||||
}
|
||||
token = token.WithExtra(extra)
|
||||
|
||||
@@ -192,6 +192,6 @@ func (proxy PluginProxy) logRequest() {
|
||||
}
|
||||
|
||||
type templateData struct {
|
||||
JsonData map[string]interface{}
|
||||
JsonData map[string]any
|
||||
SecureJsonData map[string]string
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestPluginProxy(t *testing.T) {
|
||||
req := getPluginProxiedRequest(
|
||||
t,
|
||||
&pluginsettings.DTO{
|
||||
JSONData: map[string]interface{}{
|
||||
JSONData: map[string]any{
|
||||
"dynamicUrl": "https://dynamic.grafana.com",
|
||||
},
|
||||
},
|
||||
@@ -212,7 +212,7 @@ func TestPluginProxy(t *testing.T) {
|
||||
req := getPluginProxiedRequest(
|
||||
t,
|
||||
&pluginsettings.DTO{
|
||||
JSONData: map[string]interface{}{"dynamicUrl": "https://dynamic.grafana.com"},
|
||||
JSONData: map[string]any{"dynamicUrl": "https://dynamic.grafana.com"},
|
||||
SecureJSONData: encryptedJsonData,
|
||||
},
|
||||
secretsService,
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
token map[string]interface{}
|
||||
token map[string]any
|
||||
)
|
||||
|
||||
func TestAccessToken_pluginWithTokenAuthRoute(t *testing.T) {
|
||||
@@ -68,8 +68,8 @@ func TestAccessToken_pluginWithTokenAuthRoute(t *testing.T) {
|
||||
t.Run("Should parse token, with different fields and types", func(t *testing.T) {
|
||||
type tokenTestDescription struct {
|
||||
desc string
|
||||
expiresIn interface{}
|
||||
expiresOn interface{}
|
||||
expiresIn any
|
||||
expiresOn any
|
||||
expectedExpiresOn int64
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func TestAccessToken_pluginWithTokenAuthRoute(t *testing.T) {
|
||||
// reset the httphandler counter
|
||||
authCalls = 0
|
||||
|
||||
token = map[string]interface{}{
|
||||
token = map[string]any{
|
||||
"access_token": "2YotnFZFEjr1zCsicMWpAA",
|
||||
"token_type": "example",
|
||||
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
|
||||
@@ -159,7 +159,7 @@ func TestAccessToken_pluginWithTokenAuthRoute(t *testing.T) {
|
||||
defer resetTimeNow()
|
||||
provider := newGenericAccessTokenProvider(DSInfo{}, pluginRoute, authParams)
|
||||
|
||||
token = map[string]interface{}{
|
||||
token = map[string]any{
|
||||
"access_token": "2YotnFZFEjr1zCsicMWpAA",
|
||||
"token_type": "3600",
|
||||
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
|
||||
@@ -181,7 +181,7 @@ func clearTokenCache() {
|
||||
tokenCache.Lock()
|
||||
defer tokenCache.Unlock()
|
||||
tokenCache.cache = map[string]*jwtToken{}
|
||||
token = map[string]interface{}{}
|
||||
token = map[string]any{}
|
||||
}
|
||||
|
||||
func mockTimeNow(timeSeed time.Time) {
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// interpolateString accepts template data and return a string with substitutions
|
||||
func interpolateString(text string, data templateData) (string, error) {
|
||||
extraFuncs := map[string]interface{}{
|
||||
"orEmpty": func(v interface{}) interface{} {
|
||||
extraFuncs := map[string]any{
|
||||
"orEmpty": func(v any) any {
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
+2
-2
@@ -407,14 +407,14 @@ func (hs *HTTPServer) CheckHealth(c *contextmodel.ReqContext) response.Response
|
||||
return translatePluginRequestErrorToAPIError(err)
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
payload := map[string]any{
|
||||
"status": resp.Status.String(),
|
||||
"message": resp.Message,
|
||||
}
|
||||
|
||||
// Unmarshal JSONDetails if it's not empty.
|
||||
if len(resp.JSONDetails) > 0 {
|
||||
var jsonDetails map[string]interface{}
|
||||
var jsonDetails map[string]any
|
||||
err = json.Unmarshal(resp.JSONDetails, &jsonDetails)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to unmarshal detailed response from backend plugin", err)
|
||||
|
||||
@@ -272,7 +272,7 @@ func Test_GetPluginAssets(t *testing.T) {
|
||||
setting.NewCfg(), service, func(sc *scenarioContext) {
|
||||
callGetPluginAsset(sc)
|
||||
|
||||
var respJson map[string]interface{}
|
||||
var respJson map[string]any
|
||||
err := json.NewDecoder(sc.resp.Body).Decode(&respJson)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 404, sc.resp.Code)
|
||||
@@ -287,7 +287,7 @@ func Test_GetPluginAssets(t *testing.T) {
|
||||
setting.NewCfg(), fakes.NewFakePluginRegistry(), func(sc *scenarioContext) {
|
||||
callGetPluginAsset(sc)
|
||||
|
||||
var respJson map[string]interface{}
|
||||
var respJson map[string]any
|
||||
err := json.NewDecoder(sc.resp.Body).Decode(&respJson)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 404, sc.resp.Code)
|
||||
@@ -520,7 +520,7 @@ type fakePluginClient struct {
|
||||
|
||||
func (c *fakePluginClient) CallResource(_ context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||
c.req = req
|
||||
bytes, err := json.Marshal(map[string]interface{}{
|
||||
bytes, err := json.Marshal(map[string]any{
|
||||
"message": "hello",
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -98,7 +98,7 @@ func (r *NormalResponse) WriteTo(ctx *contextmodel.ReqContext) {
|
||||
}
|
||||
|
||||
func (r *NormalResponse) writeLogLine(c *contextmodel.ReqContext) {
|
||||
v := map[string]interface{}{}
|
||||
v := map[string]any{}
|
||||
traceID := tracing.TraceIDFromContext(c.Req.Context(), false)
|
||||
if err := json.Unmarshal(r.body.Bytes(), &v); err == nil {
|
||||
v["traceID"] = traceID
|
||||
@@ -122,7 +122,7 @@ func (r *NormalResponse) SetHeader(key, value string) *NormalResponse {
|
||||
|
||||
// StreamingResponse is a response that streams itself back to the client.
|
||||
type StreamingResponse struct {
|
||||
body interface{}
|
||||
body any
|
||||
status int
|
||||
header http.Header
|
||||
}
|
||||
@@ -181,13 +181,13 @@ func (r *RedirectResponse) Body() []byte {
|
||||
}
|
||||
|
||||
// JSON creates a JSON response.
|
||||
func JSON(status int, body interface{}) *NormalResponse {
|
||||
func JSON(status int, body any) *NormalResponse {
|
||||
return Respond(status, body).
|
||||
SetHeader("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
// JSONStreaming creates a streaming JSON response.
|
||||
func JSONStreaming(status int, body interface{}) StreamingResponse {
|
||||
func JSONStreaming(status int, body any) StreamingResponse {
|
||||
header := make(http.Header)
|
||||
header.Set("Content-Type", "application/json")
|
||||
return StreamingResponse{
|
||||
@@ -198,13 +198,13 @@ func JSONStreaming(status int, body interface{}) StreamingResponse {
|
||||
}
|
||||
|
||||
// JSONDownload creates a JSON response indicating that it should be downloaded.
|
||||
func JSONDownload(status int, body interface{}, filename string) *NormalResponse {
|
||||
func JSONDownload(status int, body any, filename string) *NormalResponse {
|
||||
return JSON(status, body).
|
||||
SetHeader("Content-Disposition", fmt.Sprintf(`attachment;filename="%s"`, filename))
|
||||
}
|
||||
|
||||
// YAML creates a YAML response.
|
||||
func YAML(status int, body interface{}) *NormalResponse {
|
||||
func YAML(status int, body any) *NormalResponse {
|
||||
b, err := yaml.Marshal(body)
|
||||
if err != nil {
|
||||
return Error(http.StatusInternalServerError, "body yaml marshal", err)
|
||||
@@ -215,7 +215,7 @@ func YAML(status int, body interface{}) *NormalResponse {
|
||||
}
|
||||
|
||||
// YAMLDownload creates a YAML response indicating that it should be downloaded.
|
||||
func YAMLDownload(status int, body interface{}, filename string) *NormalResponse {
|
||||
func YAMLDownload(status int, body any, filename string) *NormalResponse {
|
||||
return YAML(status, body).
|
||||
SetHeader("Content-Type", "application/yaml").
|
||||
SetHeader("Content-Disposition", fmt.Sprintf(`attachment;filename="%s"`, filename))
|
||||
@@ -223,14 +223,14 @@ func YAMLDownload(status int, body interface{}, filename string) *NormalResponse
|
||||
|
||||
// Success create a successful response
|
||||
func Success(message string) *NormalResponse {
|
||||
resp := make(map[string]interface{})
|
||||
resp := make(map[string]any)
|
||||
resp["message"] = message
|
||||
return JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// Error creates an error response.
|
||||
func Error(status int, message string, err error) *NormalResponse {
|
||||
data := make(map[string]interface{})
|
||||
data := make(map[string]any)
|
||||
|
||||
switch status {
|
||||
case 404:
|
||||
@@ -295,7 +295,7 @@ func Empty(status int) *NormalResponse {
|
||||
}
|
||||
|
||||
// Respond creates a response.
|
||||
func Respond(status int, body interface{}) *NormalResponse {
|
||||
func Respond(status int, body any) *NormalResponse {
|
||||
var b []byte
|
||||
switch t := body.(type) {
|
||||
case []byte:
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func swaggerUI(c *contextmodel.ReqContext) {
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Nonce": c.RequestNonce,
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestUserAPIEndpoint_userLoggedIn(t *testing.T) {
|
||||
TokenType: "Bearer",
|
||||
}
|
||||
idToken := "testidtoken"
|
||||
token = token.WithExtra(map[string]interface{}{"id_token": idToken})
|
||||
token = token.WithExtra(map[string]any{"id_token": idToken})
|
||||
userlogin := "loginuser"
|
||||
query := &login.GetUserByAuthInfoQuery{AuthModule: "test", AuthId: "test", UserLookupParams: login.UserLookupParams{Login: &userlogin}}
|
||||
cmd := &login.UpdateAuthInfoCommand{
|
||||
|
||||
Reference in New Issue
Block a user