Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -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 ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user