Chore: use any rather than interface{} (#74066)

This commit is contained in:
Ryan McKinley
2023-08-30 18:46:47 +03:00
committed by GitHub
parent 3e272d2bda
commit 025b2f3011
525 changed files with 2528 additions and 2528 deletions
@@ -12,7 +12,7 @@ import (
)
func TestAngularPatternsStore(t *testing.T) {
mockPatterns := []map[string]interface{}{
mockPatterns := []map[string]any{
{"name": "PanelCtrl", "type": "contains", "pattern": "PanelCtrl"},
{"name": "ConfigCtrl", "type": "contains", "pattern": "ConfigCtrl"},
}
@@ -27,7 +27,7 @@ func TestCachingMiddleware(t *testing.T) {
clienttest.WithMiddlewares(NewCachingMiddleware(cs)),
)
jsonDataMap := map[string]interface{}{}
jsonDataMap := map[string]any{}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
require.NoError(t, err)
@@ -202,7 +202,7 @@ func TestCachingMiddleware(t *testing.T) {
clienttest.WithResourceResponses([]*backend.CallResourceResponse{simulatedPluginResponse}),
)
jsonDataMap := map[string]interface{}{}
jsonDataMap := map[string]any{}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
require.NoError(t, err)
@@ -279,7 +279,7 @@ func TestCachingMiddleware(t *testing.T) {
reqCtx := contexthandler.FromContext(req.Context())
require.Nil(t, reqCtx)
jsonDataMap := map[string]interface{}{}
jsonDataMap := map[string]any{}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
require.NoError(t, err)
@@ -30,7 +30,7 @@ type CookiesMiddleware struct {
skipCookiesNames []string
}
func (m *CookiesMiddleware) applyCookies(ctx context.Context, pCtx backend.PluginContext, req interface{}) error {
func (m *CookiesMiddleware) applyCookies(ctx context.Context, pCtx backend.PluginContext, req any) error {
reqCtx := contexthandler.FromContext(ctx)
// if request not for a datasource or no HTTP request context skip middleware
if req == nil || pCtx.DataSourceInstanceSettings == nil || reqCtx == nil || reqCtx.Req == nil {
@@ -33,7 +33,7 @@ func TestCookiesMiddleware(t *testing.T) {
clienttest.WithMiddlewares(NewCookiesMiddleware([]string{"grafana_session"})),
)
jsonDataMap := map[string]interface{}{}
jsonDataMap := map[string]any{}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
require.NoError(t, err)
@@ -102,7 +102,7 @@ func TestCookiesMiddleware(t *testing.T) {
clienttest.WithMiddlewares(NewCookiesMiddleware([]string{"grafana_session"})),
)
jsonDataMap := map[string]interface{}{
jsonDataMap := map[string]any{
"keepCookies": []string{"cookie2", "grafana_session"},
}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
@@ -26,7 +26,7 @@ type HTTPClientMiddleware struct {
next plugins.Client
}
func (m *HTTPClientMiddleware) applyHeaders(ctx context.Context, pReq interface{}) context.Context {
func (m *HTTPClientMiddleware) applyHeaders(ctx context.Context, pReq any) context.Context {
if pReq == nil {
return ctx
}
@@ -28,7 +28,7 @@ func TestOAuthTokenMiddleware(t *testing.T) {
clienttest.WithMiddlewares(NewOAuthTokenMiddleware(oAuthTokenService)),
)
jsonDataMap := map[string]interface{}{}
jsonDataMap := map[string]any{}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
require.NoError(t, err)
@@ -82,7 +82,7 @@ func TestOAuthTokenMiddleware(t *testing.T) {
TokenType: "bearer",
AccessToken: "access-token",
}
token = token.WithExtra(map[string]interface{}{"id_token": "id-token"})
token = token.WithExtra(map[string]any{"id_token": "id-token"})
oAuthTokenService := &oauthtokentest.Service{
Token: token,
}
@@ -91,7 +91,7 @@ func TestOAuthTokenMiddleware(t *testing.T) {
clienttest.WithMiddlewares(NewOAuthTokenMiddleware(oAuthTokenService)),
)
jsonDataMap := map[string]interface{}{
jsonDataMap := map[string]any{
"oauthPassThru": true,
}
jsonDataBytes, err := json.Marshal(&jsonDataMap)
@@ -14,7 +14,7 @@ type DTO struct {
OrgID int64
PluginID string
PluginVersion string
JSONData map[string]interface{}
JSONData map[string]any
SecureJSONData map[string][]byte
Enabled bool
Pinned bool
@@ -32,7 +32,7 @@ type InfoDTO struct {
type UpdateArgs struct {
Enabled bool
Pinned bool
JSONData map[string]interface{}
JSONData map[string]any
SecureJSONData map[string]string
PluginVersion string
PluginID string
@@ -61,7 +61,7 @@ type PluginSetting struct {
OrgId int64
Enabled bool
Pinned bool
JsonData map[string]interface{}
JsonData map[string]any
SecureJsonData map[string][]byte
PluginVersion string
@@ -82,11 +82,11 @@ type PluginSettingInfo struct {
// Also acts as api DTO
type UpdatePluginSettingCmd struct {
Enabled bool `json:"enabled"`
Pinned bool `json:"pinned"`
JsonData map[string]interface{} `json:"jsonData"`
SecureJsonData map[string]string `json:"secureJsonData"`
PluginVersion string `json:"version"`
Enabled bool `json:"enabled"`
Pinned bool `json:"pinned"`
JsonData map[string]any `json:"jsonData"`
SecureJsonData map[string]string `json:"secureJsonData"`
PluginVersion string `json:"version"`
PluginId string `json:"-"`
OrgId int64 `json:"-"`
@@ -136,7 +136,7 @@ func (s *Service) DecryptedValues(ps *pluginsettings.DTO) map[string]string {
func (s *Service) getPluginSettingsInfo(ctx context.Context, orgID int64) ([]*pluginsettings.PluginSettingInfo, error) {
sql := `SELECT org_id, plugin_id, enabled, pinned, plugin_version FROM plugin_setting `
params := make([]interface{}, 0)
params := make([]any, 0)
if orgID != 0 {
sql += "WHERE org_id=?"
@@ -30,7 +30,7 @@ func TestService_DecryptedValuesCache(t *testing.T) {
ps := pluginsettings.DTO{
ID: 1,
JSONData: map[string]interface{}{},
JSONData: map[string]any{},
SecureJSONData: encryptedJsonData,
}
@@ -68,7 +68,7 @@ func TestService_DecryptedValuesCache(t *testing.T) {
ps := pluginsettings.DTO{
ID: 1,
JSONData: map[string]interface{}{},
JSONData: map[string]any{},
SecureJSONData: encryptedJsonData,
}
@@ -110,7 +110,7 @@ func TestIntegrationPluginSettings(t *testing.T) {
PluginId: "existing",
Enabled: false,
Pinned: false,
JsonData: map[string]interface{}{
JsonData: map[string]any{
"key": "value",
},
SecureJsonData: secureJsonData,
@@ -177,7 +177,7 @@ func TestIntegrationPluginSettings(t *testing.T) {
PluginID: existing.PluginId,
Enabled: true,
PluginVersion: "1.0.1",
JSONData: map[string]interface{}{
JSONData: map[string]any{
"key2": "value2",
},
SecureJSONData: map[string]string{
@@ -235,7 +235,7 @@ func TestIntegrationPluginSettings(t *testing.T) {
Enabled: true,
OrgID: 1,
PluginVersion: "1.0.0",
JSONData: map[string]interface{}{
JSONData: map[string]any{
"key": "value",
},
SecureJSONData: map[string]string{