Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -79,7 +79,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := getRequest(t, alertsURL, http.StatusNotFound) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "no admin configuration available", res["message"])
|
||||
@@ -99,7 +99,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusBadRequest) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Invalid alertmanager choice specified", res["message"])
|
||||
@@ -120,7 +120,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusBadRequest) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "At least one Alertmanager must be provided or configured as a datasource that handles alerts to choose this option", res["message"])
|
||||
@@ -134,7 +134,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
URL: fakeAM1.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
}),
|
||||
@@ -147,7 +147,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, dataSourcesUrl, buf.String(), http.StatusOK) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Datasource added", res["message"])
|
||||
@@ -161,7 +161,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
URL: fakeAM2.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
}),
|
||||
@@ -174,7 +174,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, dataSourcesUrl, buf.String(), http.StatusOK) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Datasource added", res["message"])
|
||||
@@ -195,7 +195,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusCreated) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "admin configuration updated", res["message"])
|
||||
@@ -290,7 +290,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
Type: datasources.DS_ALERTMANAGER,
|
||||
Access: "proxy",
|
||||
URL: fakeAM3.URL(),
|
||||
JsonData: simplejson.NewFromAny(map[string]interface{}{
|
||||
JsonData: simplejson.NewFromAny(map[string]any{
|
||||
"handleGrafanaManagedAlerts": true,
|
||||
"implementation": "prometheus",
|
||||
}),
|
||||
@@ -303,7 +303,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, dataSourcesUrl, buf.String(), http.StatusOK) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Datasource added", res["message"])
|
||||
@@ -322,7 +322,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusCreated) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "admin configuration updated", res["message"])
|
||||
|
||||
@@ -100,7 +100,7 @@ func TestIntegrationAlertmanagerConfigurationIsTransactional(t *testing.T) {
|
||||
resp := postRequest(t, alertConfigURL, payload, http.StatusBadRequest) // nolint
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Regexp(t, `^failed to save and apply Alertmanager configuration: failed to validate integration "slack.receiver" \(UID [^\)]+\) of type "slack": token must be specified when using the Slack chat API`, res["message"])
|
||||
resp = getRequest(t, alertConfigURL, http.StatusOK) // nolint
|
||||
@@ -223,7 +223,7 @@ func TestIntegrationAlertmanagerConfigurationPersistSecrets(t *testing.T) {
|
||||
|
||||
resp := postRequest(t, alertConfigURL, payload, http.StatusBadRequest) // nolint
|
||||
s := getBody(t, resp.Body)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(s), &res))
|
||||
require.Equal(t, "unknown receiver: invalid", res["message"])
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ func TestIntegrationAlertAndGroupsQuery(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusUnauthorized, resp.StatusCode)
|
||||
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
assert.Equal(t, "Invalid username or password", res["message"])
|
||||
}
|
||||
@@ -1341,7 +1341,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
|
||||
status, body := apiClient.PostRulesGroup(t, "default", &rules)
|
||||
assert.Equal(t, http.StatusNotFound, status)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
assert.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "failed to update rule group: failed to update rule with UID unknown because could not find alert rule", res["message"])
|
||||
|
||||
@@ -1447,7 +1447,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
}
|
||||
status, body := apiClient.PostRulesGroup(t, "default", &rules)
|
||||
assert.Equal(t, http.StatusBadRequest, status)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, fmt.Sprintf("rule [1] has UID %s that is already assigned to another rule at index 0", ruleUID), res["message"])
|
||||
|
||||
@@ -1813,7 +1813,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, http.StatusAccepted, resp.StatusCode)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, "rules deleted", res["message"])
|
||||
})
|
||||
@@ -1995,7 +1995,7 @@ func TestIntegrationQuota(t *testing.T) {
|
||||
}
|
||||
status, body := apiClient.PostRulesGroup(t, "default", &rules)
|
||||
assert.Equal(t, http.StatusForbidden, status)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "quota has been exceeded", res["message"])
|
||||
})
|
||||
|
||||
@@ -210,7 +210,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, 400, resp.StatusCode)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, "invalid rule specification at index [0]: both annotations __dashboardUid__ and __panelId__ must be specified", res["message"])
|
||||
}
|
||||
@@ -618,7 +618,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, `invalid panel_id: strconv.ParseInt: parsing "invalid": invalid syntax`, res["message"])
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, "panel_id must be set with dashboard_uid", res["message"])
|
||||
}
|
||||
@@ -802,5 +802,5 @@ type rulesData struct {
|
||||
type groupData struct {
|
||||
Name string
|
||||
File string
|
||||
Rules []interface{}
|
||||
Rules []any
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ func TestIntegrationAlertRuleConflictingTitle(t *testing.T) {
|
||||
status, body := apiClient.PostRulesGroup(t, "folder1", &rulesWithUID)
|
||||
assert.Equal(t, http.StatusInternalServerError, status)
|
||||
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "failed to update rule group: failed to add rules: a conflicting alert rule is found: rule title under the same organisation and folder should be unique", res["message"])
|
||||
})
|
||||
@@ -383,7 +383,7 @@ func TestIntegrationAlertRuleConflictingTitle(t *testing.T) {
|
||||
status, body := apiClient.PostRulesGroup(t, "folder1", &rulesWithUID)
|
||||
assert.Equal(t, http.StatusInternalServerError, status)
|
||||
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "failed to update rule group: failed to update rules: a conflicting alert rule is found: rule title under the same organisation and folder should be unique", res["message"])
|
||||
})
|
||||
@@ -736,7 +736,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, `invalid panel_id: strconv.ParseInt: parsing "invalid": invalid syntax`, res["message"])
|
||||
}
|
||||
@@ -754,7 +754,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
var res map[string]interface{}
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal(b, &res))
|
||||
require.Equal(t, "panel_id must be set with dashboard_uid", res["message"])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user