mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: use any rather than interface{} (#74066)
This commit is contained in:
parent
3e272d2bda
commit
025b2f3011
@ -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"`
|
||||
|
||||
|
@ -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",
|
||||
},
|
||||
}),
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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{
|
||||
|
@ -232,7 +232,7 @@ func getSHA256(u string) ([]byte, error) {
|
||||
return sha256, nil
|
||||
}
|
||||
|
||||
func postRequest(cfg packaging.PublishConfig, pth string, obj interface{}, descr string) error {
|
||||
func postRequest(cfg packaging.PublishConfig, pth string, obj any, descr string) error {
|
||||
var sfx string
|
||||
switch cfg.Edition {
|
||||
case config.EditionOSS:
|
||||
|
@ -68,7 +68,7 @@ func VerifyDrone(c *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func readConfig(fpath string) ([]map[string]interface{}, error) {
|
||||
func readConfig(fpath string) ([]map[string]any, error) {
|
||||
//nolint:gosec
|
||||
f, err := os.Open(fpath)
|
||||
if err != nil {
|
||||
@ -82,9 +82,9 @@ func readConfig(fpath string) ([]map[string]interface{}, error) {
|
||||
|
||||
// The YAML stream may contain multiple pipeline configurations, read them all
|
||||
dec := yaml.NewDecoder(f)
|
||||
var c []map[string]interface{}
|
||||
var c []map[string]any
|
||||
for {
|
||||
var m map[string]interface{}
|
||||
var m map[string]any
|
||||
if err := dec.Decode(&m); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
|
@ -94,7 +94,7 @@ func GetPackageJSONVersion(grafanaDir string) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to read %q: %w", pkgJSONPath, err)
|
||||
}
|
||||
pkgObj := map[string]interface{}{}
|
||||
pkgObj := map[string]any{}
|
||||
if err := json.Unmarshal(pkgJSONB, &pkgObj); err != nil {
|
||||
return "", fmt.Errorf("failed decoding %q: %w", pkgJSONPath, err)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func GetLernaVersion(grafanaDir string) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to read %q: %w", lernaJSONPath, err)
|
||||
}
|
||||
pkgObj := map[string]interface{}{}
|
||||
pkgObj := map[string]any{}
|
||||
if err := json.Unmarshal(lernaJSONB, &pkgObj); err != nil {
|
||||
return "", fmt.Errorf("failed decoding %q: %w", lernaJSONPath, err)
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ func copyPlugins(ctx context.Context, v config.Variant, grafanaDir, tmpDir strin
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read %q: %w", filepath.Join(srcDir, "plugin.json"), err)
|
||||
}
|
||||
var plugJSON map[string]interface{}
|
||||
var plugJSON map[string]any
|
||||
if err := json.Unmarshal(jsonB, &plugJSON); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
)
|
||||
|
||||
// HandlerFunc defines a handler function interface.
|
||||
type HandlerFunc interface{}
|
||||
type HandlerFunc any
|
||||
|
||||
// Msg defines a message interface.
|
||||
type Msg interface{}
|
||||
type Msg any
|
||||
|
||||
// ErrHandlerNotFound defines an error if a handler is not found.
|
||||
var ErrHandlerNotFound = errors.New("handler not found")
|
||||
|
@ -51,6 +51,6 @@ func (ffi FakeFileInfo) ModTime() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (ffi FakeFileInfo) Sys() interface{} {
|
||||
func (ffi FakeFileInfo) Sys() any {
|
||||
return nil
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ func (r *ConflictResolver) showChanges() {
|
||||
|
||||
// Formatter make it possible for us to write to terminal and to a file
|
||||
// with different formats depending on the usecase
|
||||
type Formatter func(format string, a ...interface{}) string
|
||||
type Formatter func(format string, a ...any) string
|
||||
|
||||
func shouldDiscardBlock(seenUsersInBlock map[string]string, block string, user ConflictingUser) bool {
|
||||
// loop through users to see if we should skip this block
|
||||
|
@ -95,7 +95,7 @@ func updateRows(session *db.Session, rows []map[string][]byte, passwordFieldName
|
||||
return 0, fmt.Errorf("%v: %w", "marshaling newSecureJsonData failed", err)
|
||||
}
|
||||
|
||||
newRow := map[string]interface{}{"secure_json_data": data, passwordFieldName: ""}
|
||||
newRow := map[string]any{"secure_json_data": data, passwordFieldName: ""}
|
||||
session.Table("data_source")
|
||||
session.Where("id = ?", string(row["id"]))
|
||||
// Setting both columns while having value only for secure_json_data should clear the [passwordFieldName] column
|
||||
@ -111,20 +111,20 @@ func updateRows(session *db.Session, rows []map[string][]byte, passwordFieldName
|
||||
return rowsUpdated, nil
|
||||
}
|
||||
|
||||
func getUpdatedSecureJSONData(row map[string][]byte, passwordFieldName string) (map[string]interface{}, error) {
|
||||
func getUpdatedSecureJSONData(row map[string][]byte, passwordFieldName string) (map[string]any, error) {
|
||||
encryptedPassword, err := util.Encrypt(row[passwordFieldName], setting.SecretKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var secureJSONData map[string]interface{}
|
||||
var secureJSONData map[string]any
|
||||
|
||||
if len(row["secure_json_data"]) > 0 {
|
||||
if err := json.Unmarshal(row["secure_json_data"], &secureJSONData); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
secureJSONData = map[string]interface{}{}
|
||||
secureJSONData = map[string]any{}
|
||||
}
|
||||
|
||||
jsonFieldName := util.ToCamelCase(passwordFieldName)
|
||||
|
@ -8,39 +8,39 @@ var (
|
||||
debugmode = false
|
||||
)
|
||||
|
||||
func Debug(args ...interface{}) {
|
||||
func Debug(args ...any) {
|
||||
if debugmode {
|
||||
fmt.Print(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func Debugf(fmtString string, args ...interface{}) {
|
||||
func Debugf(fmtString string, args ...any) {
|
||||
if debugmode {
|
||||
fmt.Printf(fmtString, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func Error(args ...interface{}) {
|
||||
func Error(args ...any) {
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func Errorf(fmtString string, args ...interface{}) {
|
||||
func Errorf(fmtString string, args ...any) {
|
||||
fmt.Printf(fmtString, args...)
|
||||
}
|
||||
|
||||
func Info(args ...interface{}) {
|
||||
func Info(args ...any) {
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func Infof(fmtString string, args ...interface{}) {
|
||||
func Infof(fmtString string, args ...any) {
|
||||
fmt.Printf(fmtString, args...)
|
||||
}
|
||||
|
||||
func Warn(args ...interface{}) {
|
||||
func Warn(args ...any) {
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func Warnf(fmtString string, args ...interface{}) {
|
||||
func Warnf(fmtString string, args ...any) {
|
||||
fmt.Printf(fmtString, args...)
|
||||
}
|
||||
|
||||
|
@ -17,51 +17,51 @@ func New(debugMode bool) *CLILogger {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CLILogger) Successf(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Successf(format string, args ...any) {
|
||||
fmt.Printf(fmt.Sprintf("%s %s\n\n", color.GreenString("✔"), format), args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Failuref(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Failuref(format string, args ...any) {
|
||||
fmt.Printf(fmt.Sprintf("%s %s %s\n\n", color.RedString("Error"), color.RedString("✗"), format), args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Info(args ...interface{}) {
|
||||
func (l *CLILogger) Info(args ...any) {
|
||||
args = append(args, "\n\n")
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Infof(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Infof(format string, args ...any) {
|
||||
fmt.Printf(addNewlines(format), args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Debug(args ...interface{}) {
|
||||
func (l *CLILogger) Debug(args ...any) {
|
||||
args = append(args, "\n\n")
|
||||
if l.debugMode {
|
||||
fmt.Print(color.HiBlueString(fmt.Sprint(args...)))
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CLILogger) Debugf(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Debugf(format string, args ...any) {
|
||||
if l.debugMode {
|
||||
fmt.Print(color.HiBlueString(fmt.Sprintf(addNewlines(format), args...)))
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CLILogger) Warn(args ...interface{}) {
|
||||
func (l *CLILogger) Warn(args ...any) {
|
||||
args = append(args, "\n\n")
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Warnf(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Warnf(format string, args ...any) {
|
||||
fmt.Printf(addNewlines(format), args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Error(args ...interface{}) {
|
||||
func (l *CLILogger) Error(args ...any) {
|
||||
args = append(args, "\n\n")
|
||||
fmt.Print(args...)
|
||||
}
|
||||
|
||||
func (l *CLILogger) Errorf(format string, args ...interface{}) {
|
||||
func (l *CLILogger) Errorf(format string, args ...any) {
|
||||
fmt.Printf(addNewlines(format), args...)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ type CommandLine interface {
|
||||
String(name string) string
|
||||
StringSlice(name string) []string
|
||||
FlagNames() (names []string)
|
||||
Generic(name string) interface{}
|
||||
Generic(name string) any
|
||||
|
||||
PluginDirectory() string
|
||||
PluginRepoURL() string
|
||||
|
@ -75,15 +75,15 @@ func (_m *MockCommandLine) FlagNames() []string {
|
||||
}
|
||||
|
||||
// Generic provides a mock function with given fields: name
|
||||
func (_m *MockCommandLine) Generic(name string) interface{} {
|
||||
func (_m *MockCommandLine) Generic(name string) any {
|
||||
ret := _m.Called(name)
|
||||
|
||||
var r0 interface{}
|
||||
if rf, ok := ret.Get(0).(func(string) interface{}); ok {
|
||||
var r0 any
|
||||
if rf, ok := ret.Get(0).(func(string) any); ok {
|
||||
r0 = rf(name)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(interface{})
|
||||
r0 = ret.Get(0).(any)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,7 +740,7 @@ func (pts *PropertyTypes) HasType(pt PropertyType) bool {
|
||||
}
|
||||
|
||||
func (pts *PropertyTypes) UnmarshalJSON(data []byte) error {
|
||||
var value interface{}
|
||||
var value any
|
||||
if err := json.Unmarshal(data, &value); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -749,7 +749,7 @@ func (pts *PropertyTypes) UnmarshalJSON(data []byte) error {
|
||||
case string:
|
||||
*pts = []PropertyType{PropertyType(val)}
|
||||
return nil
|
||||
case []interface{}:
|
||||
case []any:
|
||||
var pt []PropertyType
|
||||
for _, t := range val {
|
||||
s, ok := t.(string)
|
||||
@ -778,7 +778,7 @@ const (
|
||||
)
|
||||
|
||||
type Any struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
func (u *Any) UnmarshalJSON(data []byte) error {
|
||||
|
@ -348,7 +348,7 @@ func allowedTSVeneersString() string {
|
||||
return strings.Join(list, "|")
|
||||
}
|
||||
|
||||
func valError(v cue.Value, format string, args ...interface{}) error {
|
||||
func valError(v cue.Value, format string, args ...any) error {
|
||||
s := v.Source()
|
||||
if s == nil {
|
||||
return fmt.Errorf(format, args...)
|
||||
|
@ -95,7 +95,7 @@ func CalculateDiff(ctx context.Context, options *Options, baseData, newData *sim
|
||||
}
|
||||
|
||||
// getDiff computes the diff of two dashboard versions.
|
||||
func getDiff(baseData, newData *simplejson.Json) (interface{}, diff.Diff, error) {
|
||||
func getDiff(baseData, newData *simplejson.Json) (any, diff.Diff, error) {
|
||||
leftBytes, err := baseData.Encode()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -115,7 +115,7 @@ func getDiff(baseData, newData *simplejson.Json) (interface{}, diff.Diff, error)
|
||||
return nil, nil, ErrNilDiff
|
||||
}
|
||||
|
||||
left := make(map[string]interface{})
|
||||
left := make(map[string]any)
|
||||
err = json.Unmarshal(leftBytes, &left)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -22,8 +22,8 @@ type BasicDiff struct {
|
||||
// A BasicBlock represents a top-level element in a basic diff.
|
||||
type BasicBlock struct {
|
||||
Title string
|
||||
Old interface{}
|
||||
New interface{}
|
||||
Old any
|
||||
New any
|
||||
Change ChangeType
|
||||
Changes []*BasicChange
|
||||
Summaries []*BasicSummary
|
||||
@ -35,8 +35,8 @@ type BasicBlock struct {
|
||||
// BasicChanges in a BasicBlock.
|
||||
type BasicChange struct {
|
||||
Key string
|
||||
Old interface{}
|
||||
New interface{}
|
||||
Old any
|
||||
New any
|
||||
Change ChangeType
|
||||
LineStart int
|
||||
LineEnd int
|
||||
@ -60,7 +60,7 @@ type BasicFormatter struct {
|
||||
tpl *template.Template
|
||||
}
|
||||
|
||||
func NewBasicFormatter(left interface{}) *BasicFormatter {
|
||||
func NewBasicFormatter(left any) *BasicFormatter {
|
||||
tpl := template.Must(template.New("block").Funcs(tplFuncMap).Parse(tplBlock))
|
||||
tpl = template.Must(tpl.New("change").Funcs(tplFuncMap).Parse(tplChange))
|
||||
tpl = template.Must(tpl.New("summary").Funcs(tplFuncMap).Parse(tplSummary))
|
||||
|
@ -86,17 +86,17 @@ var diffTplFuncs = template.FuncMap{
|
||||
// and contains the data required to produce the tokens output in the basic
|
||||
// diff.
|
||||
type JSONLine struct {
|
||||
LineNum int `json:"line"`
|
||||
LeftLine int `json:"leftLine"`
|
||||
RightLine int `json:"rightLine"`
|
||||
Indent int `json:"indent"`
|
||||
Text string `json:"text"`
|
||||
Change ChangeType `json:"changeType"`
|
||||
Key string `json:"key"`
|
||||
Val interface{} `json:"value"`
|
||||
LineNum int `json:"line"`
|
||||
LeftLine int `json:"leftLine"`
|
||||
RightLine int `json:"rightLine"`
|
||||
Indent int `json:"indent"`
|
||||
Text string `json:"text"`
|
||||
Change ChangeType `json:"changeType"`
|
||||
Key string `json:"key"`
|
||||
Val any `json:"value"`
|
||||
}
|
||||
|
||||
func NewJSONFormatter(left interface{}) *JSONFormatter {
|
||||
func NewJSONFormatter(left any) *JSONFormatter {
|
||||
tpl := template.Must(template.New("JSONDiffWrapper").Funcs(diffTplFuncs).Parse(tplJSONDiffWrapper))
|
||||
tpl = template.Must(tpl.New("JSONDiffLine").Funcs(diffTplFuncs).Parse(tplJSONDiffLine))
|
||||
|
||||
@ -112,7 +112,7 @@ func NewJSONFormatter(left interface{}) *JSONFormatter {
|
||||
}
|
||||
|
||||
type JSONFormatter struct {
|
||||
left interface{}
|
||||
left any
|
||||
path []string
|
||||
size []int
|
||||
inArray []bool
|
||||
@ -130,7 +130,7 @@ type AsciiLine struct {
|
||||
|
||||
// the actual changes - no formatting
|
||||
key string
|
||||
val interface{}
|
||||
val any
|
||||
|
||||
// level of indentation for the current line
|
||||
indent int
|
||||
@ -140,16 +140,16 @@ type AsciiLine struct {
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) Format(diff diff.Diff) (result string, err error) {
|
||||
if v, ok := f.left.(map[string]interface{}); ok {
|
||||
if v, ok := f.left.(map[string]any); ok {
|
||||
if err := f.formatObject(v, diff); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else if v, ok := f.left.([]interface{}); ok {
|
||||
} else if v, ok := f.left.([]any); ok {
|
||||
if err := f.formatArray(v, diff); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
return "", fmt.Errorf("expected map[string]interface{} or []interface{}, got %T",
|
||||
return "", fmt.Errorf("expected map[string]any or []any, got %T",
|
||||
f.left)
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ func (f *JSONFormatter) Format(diff diff.Diff) (result string, err error) {
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) formatObject(left map[string]interface{}, df diff.Diff) error {
|
||||
func (f *JSONFormatter) formatObject(left map[string]any, df diff.Diff) error {
|
||||
f.addLineWith(ChangeNil, "{")
|
||||
f.push("ROOT", len(left), false)
|
||||
if err := f.processObject(left, df.Deltas()); err != nil {
|
||||
@ -176,7 +176,7 @@ func (f *JSONFormatter) formatObject(left map[string]interface{}, df diff.Diff)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) formatArray(left []interface{}, df diff.Diff) error {
|
||||
func (f *JSONFormatter) formatArray(left []any, df diff.Diff) error {
|
||||
f.addLineWith(ChangeNil, "[")
|
||||
f.push("ROOT", len(left), true)
|
||||
if err := f.processArray(left, df.Deltas()); err != nil {
|
||||
@ -189,7 +189,7 @@ func (f *JSONFormatter) formatArray(left []interface{}, df diff.Diff) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) processArray(array []interface{}, deltas []diff.Delta) error {
|
||||
func (f *JSONFormatter) processArray(array []any, deltas []diff.Delta) error {
|
||||
patchedIndex := 0
|
||||
for index, value := range array {
|
||||
if err := f.processItem(value, deltas, diff.Index(index)); err != nil {
|
||||
@ -214,7 +214,7 @@ func (f *JSONFormatter) processArray(array []interface{}, deltas []diff.Delta) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) processObject(object map[string]interface{}, deltas []diff.Delta) error {
|
||||
func (f *JSONFormatter) processObject(object map[string]any, deltas []diff.Delta) error {
|
||||
names := sortKeys(object)
|
||||
for _, name := range names {
|
||||
value := object[name]
|
||||
@ -234,7 +234,7 @@ func (f *JSONFormatter) processObject(object map[string]interface{}, deltas []di
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, position diff.Position) error {
|
||||
func (f *JSONFormatter) processItem(value any, deltas []diff.Delta, position diff.Position) error {
|
||||
matchedDeltas := f.searchDeltas(deltas, position)
|
||||
positionStr := position.String()
|
||||
if len(matchedDeltas) > 0 {
|
||||
@ -242,12 +242,12 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi
|
||||
switch matchedDelta := matchedDelta.(type) {
|
||||
case *diff.Object:
|
||||
switch value.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
// ok
|
||||
default:
|
||||
return errors.New("type mismatch")
|
||||
}
|
||||
o := value.(map[string]interface{})
|
||||
o := value.(map[string]any)
|
||||
|
||||
f.newLine(ChangeNil)
|
||||
f.printKey(positionStr)
|
||||
@ -267,12 +267,12 @@ func (f *JSONFormatter) processItem(value interface{}, deltas []diff.Delta, posi
|
||||
|
||||
case *diff.Array:
|
||||
switch value.(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
// ok
|
||||
default:
|
||||
return errors.New("type mismatch")
|
||||
}
|
||||
a := value.([]interface{})
|
||||
a := value.([]any)
|
||||
|
||||
f.newLine(ChangeNil)
|
||||
f.printKey(positionStr)
|
||||
@ -416,7 +416,7 @@ func (f *JSONFormatter) printComma() {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) printValue(value interface{}) {
|
||||
func (f *JSONFormatter) printValue(value any) {
|
||||
switch value.(type) {
|
||||
case string:
|
||||
f.line.val = value
|
||||
@ -434,9 +434,9 @@ func (f *JSONFormatter) print(a string) {
|
||||
f.line.buffer.WriteString(a)
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) printRecursive(name string, value interface{}, change ChangeType) {
|
||||
func (f *JSONFormatter) printRecursive(name string, value any, change ChangeType) {
|
||||
switch value := value.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
f.newLine(change)
|
||||
f.printKey(name)
|
||||
f.print("{")
|
||||
@ -456,7 +456,7 @@ func (f *JSONFormatter) printRecursive(name string, value interface{}, change Ch
|
||||
f.printComma()
|
||||
f.closeLine()
|
||||
|
||||
case []interface{}:
|
||||
case []any:
|
||||
f.newLine(change)
|
||||
f.printKey(name)
|
||||
f.print("[")
|
||||
@ -483,7 +483,7 @@ func (f *JSONFormatter) printRecursive(name string, value interface{}, change Ch
|
||||
}
|
||||
}
|
||||
|
||||
func sortKeys(m map[string]interface{}) (keys []string) {
|
||||
func sortKeys(m map[string]any) (keys []string) {
|
||||
keys = make([]string, 0, len(m))
|
||||
for key := range m {
|
||||
keys = append(keys, key)
|
||||
|
@ -188,7 +188,7 @@ func NewStorageClient(account, accessKey string) *StorageClient {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *StorageClient) absUrl(format string, a ...interface{}) string {
|
||||
func (c *StorageClient) absUrl(format string, a ...any) string {
|
||||
part := fmt.Sprintf(format, a...)
|
||||
return fmt.Sprintf("https://%s.blob.core.windows.net/%s", c.Auth.Account, part)
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ type signedURLOptsMatcher struct {
|
||||
opts *storage.SignedURLOptions
|
||||
}
|
||||
|
||||
func (m signedURLOptsMatcher) Matches(x interface{}) bool {
|
||||
func (m signedURLOptsMatcher) Matches(x any) bool {
|
||||
suOpts, ok := x.(*storage.SignedURLOptions)
|
||||
if !ok {
|
||||
return false
|
||||
|
@ -44,7 +44,7 @@ func (m *MockImageUploader) Upload(arg0 context.Context, arg1 string) (string, e
|
||||
}
|
||||
|
||||
// Upload indicates an expected call of Upload.
|
||||
func (mr *MockImageUploaderMockRecorder) Upload(arg0, arg1 interface{}) *gomock.Call {
|
||||
func (mr *MockImageUploaderMockRecorder) Upload(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Upload", reflect.TypeOf((*MockImageUploader)(nil).Upload), arg0, arg1)
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ var fileDescriptor_7a8976f235a02f79 = []byte{
|
||||
0x10, 0x6d, 0x6a, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *PushRequest) Equal(that interface{}) bool {
|
||||
func (this *PushRequest) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
@ -284,7 +284,7 @@ func (this *PushRequest) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *PushResponse) Equal(that interface{}) bool {
|
||||
func (this *PushResponse) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
@ -305,7 +305,7 @@ func (this *PushResponse) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *StreamAdapter) Equal(that interface{}) bool {
|
||||
func (this *StreamAdapter) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
@ -340,7 +340,7 @@ func (this *StreamAdapter) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *EntryAdapter) Equal(that interface{}) bool {
|
||||
func (this *EntryAdapter) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
@ -415,7 +415,7 @@ func (this *EntryAdapter) GoString() string {
|
||||
s = append(s, "}")
|
||||
return strings.Join(s, "")
|
||||
}
|
||||
func valueToGoStringLogproto(v interface{}, typ string) string {
|
||||
func valueToGoStringLogproto(v any, typ string) string {
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsNil() {
|
||||
return "nil"
|
||||
@ -473,7 +473,7 @@ func RegisterPusherServer(s *grpc.Server, srv PusherServer) {
|
||||
s.RegisterService(&_Pusher_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Pusher_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Pusher_Push_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(PushRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
@ -485,7 +485,7 @@ func _Pusher_Push_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
Server: srv,
|
||||
FullMethod: "/logproto.Pusher/Push",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(PusherServer).Push(ctx, req.(*PushRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
@ -776,7 +776,7 @@ func (this *EntryAdapter) String() string {
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func valueToStringLogproto(v interface{}) string {
|
||||
func valueToStringLogproto(v any) string {
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsNil() {
|
||||
return "nil"
|
||||
|
@ -405,7 +405,7 @@ func (m *Entry) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Stream) Equal(that interface{}) bool {
|
||||
func (m *Stream) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return m == nil
|
||||
}
|
||||
@ -438,7 +438,7 @@ func (m *Stream) Equal(that interface{}) bool {
|
||||
return m.Hash == that1.Hash
|
||||
}
|
||||
|
||||
func (m *Entry) Equal(that interface{}) bool {
|
||||
func (m *Entry) Equal(that any) bool {
|
||||
if that == nil {
|
||||
return m == nil
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ func FloatFromString(f string, nullString string) (Float, error) {
|
||||
// It also supports unmarshaling a sql.NullFloat64.
|
||||
func (f *Float) UnmarshalJSON(data []byte) error {
|
||||
var err error
|
||||
var v interface{}
|
||||
var v any
|
||||
if err = json.Unmarshal(data, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
switch x := v.(type) {
|
||||
case float64:
|
||||
f.Float64 = x
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
err = json.Unmarshal(data, &f.NullFloat64)
|
||||
case nil:
|
||||
f.Valid = false
|
||||
|
@ -20,11 +20,11 @@ func Version() string {
|
||||
}
|
||||
|
||||
type Json struct {
|
||||
data interface{}
|
||||
data any
|
||||
}
|
||||
|
||||
func (j *Json) FromDB(data []byte) error {
|
||||
j.data = make(map[string]interface{})
|
||||
j.data = make(map[string]any)
|
||||
|
||||
dec := json.NewDecoder(bytes.NewBuffer(data))
|
||||
dec.UseNumber()
|
||||
@ -39,7 +39,7 @@ func (j *Json) ToDB() ([]byte, error) {
|
||||
return j.Encode()
|
||||
}
|
||||
|
||||
func (j *Json) Scan(val interface{}) error {
|
||||
func (j *Json) Scan(val any) error {
|
||||
switch v := val.(type) {
|
||||
case []byte:
|
||||
if len(v) == 0 {
|
||||
@ -85,17 +85,17 @@ func MustJson(body []byte) *Json {
|
||||
// New returns a pointer to a new, empty `Json` object
|
||||
func New() *Json {
|
||||
return &Json{
|
||||
data: make(map[string]interface{}),
|
||||
data: make(map[string]any),
|
||||
}
|
||||
}
|
||||
|
||||
// NewFromAny returns a pointer to a new `Json` object with provided data.
|
||||
func NewFromAny(data interface{}) *Json {
|
||||
func NewFromAny(data any) *Json {
|
||||
return &Json{data: data}
|
||||
}
|
||||
|
||||
// Interface returns the underlying data
|
||||
func (j *Json) Interface() interface{} {
|
||||
func (j *Json) Interface() any {
|
||||
return j.data
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ func (j *Json) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// Set modifies `Json` map by `key` and `value`
|
||||
// Useful for changing single key/value in a `Json` object easily.
|
||||
func (j *Json) Set(key string, val interface{}) {
|
||||
func (j *Json) Set(key string, val any) {
|
||||
m, err := j.Map()
|
||||
if err != nil {
|
||||
return
|
||||
@ -126,37 +126,37 @@ func (j *Json) Set(key string, val interface{}) {
|
||||
|
||||
// SetPath modifies `Json`, recursively checking/creating map keys for the supplied path,
|
||||
// and then finally writing in the value
|
||||
func (j *Json) SetPath(branch []string, val interface{}) {
|
||||
func (j *Json) SetPath(branch []string, val any) {
|
||||
if len(branch) == 0 {
|
||||
j.data = val
|
||||
return
|
||||
}
|
||||
|
||||
// in order to insert our branch, we need map[string]interface{}
|
||||
if _, ok := (j.data).(map[string]interface{}); !ok {
|
||||
// in order to insert our branch, we need map[string]any
|
||||
if _, ok := (j.data).(map[string]any); !ok {
|
||||
// have to replace with something suitable
|
||||
j.data = make(map[string]interface{})
|
||||
j.data = make(map[string]any)
|
||||
}
|
||||
curr := j.data.(map[string]interface{})
|
||||
curr := j.data.(map[string]any)
|
||||
|
||||
for i := 0; i < len(branch)-1; i++ {
|
||||
b := branch[i]
|
||||
// key exists?
|
||||
if _, ok := curr[b]; !ok {
|
||||
n := make(map[string]interface{})
|
||||
n := make(map[string]any)
|
||||
curr[b] = n
|
||||
curr = n
|
||||
continue
|
||||
}
|
||||
|
||||
// make sure the value is the right sort of thing
|
||||
if _, ok := curr[b].(map[string]interface{}); !ok {
|
||||
if _, ok := curr[b].(map[string]any); !ok {
|
||||
// have to replace with something suitable
|
||||
n := make(map[string]interface{})
|
||||
n := make(map[string]any)
|
||||
curr[b] = n
|
||||
}
|
||||
|
||||
curr = curr[b].(map[string]interface{})
|
||||
curr = curr[b].(map[string]any)
|
||||
}
|
||||
|
||||
// add remaining k/v
|
||||
@ -238,7 +238,7 @@ func (j *Json) CheckGetIndex(index int) (*Json, bool) {
|
||||
|
||||
// SetIndex modifies `Json` array by `index` and `value`
|
||||
// for `index` in its `array` representation
|
||||
func (j *Json) SetIndex(index int, val interface{}) {
|
||||
func (j *Json) SetIndex(index int, val any) {
|
||||
a, err := j.Array()
|
||||
if err == nil {
|
||||
if len(a) > index {
|
||||
@ -266,19 +266,19 @@ func (j *Json) CheckGet(key string) (*Json, bool) {
|
||||
}
|
||||
|
||||
// Map type asserts to `map`
|
||||
func (j *Json) Map() (map[string]interface{}, error) {
|
||||
if m, ok := (j.data).(map[string]interface{}); ok {
|
||||
func (j *Json) Map() (map[string]any, error) {
|
||||
if m, ok := (j.data).(map[string]any); ok {
|
||||
return m, nil
|
||||
}
|
||||
return nil, errors.New("type assertion to map[string]interface{} failed")
|
||||
return nil, errors.New("type assertion to map[string]any failed")
|
||||
}
|
||||
|
||||
// Array type asserts to an `array`
|
||||
func (j *Json) Array() ([]interface{}, error) {
|
||||
if a, ok := (j.data).([]interface{}); ok {
|
||||
func (j *Json) Array() ([]any, error) {
|
||||
if a, ok := (j.data).([]any); ok {
|
||||
return a, nil
|
||||
}
|
||||
return nil, errors.New("type assertion to []interface{} failed")
|
||||
return nil, errors.New("type assertion to []any failed")
|
||||
}
|
||||
|
||||
// Bool type asserts to `bool`
|
||||
@ -326,15 +326,15 @@ func (j *Json) StringArray() ([]string, error) {
|
||||
return retArr, nil
|
||||
}
|
||||
|
||||
// MustArray guarantees the return of a `[]interface{}` (with optional default)
|
||||
// MustArray guarantees the return of a `[]any` (with optional default)
|
||||
//
|
||||
// useful when you want to iterate over array values in a succinct manner:
|
||||
//
|
||||
// for i, v := range js.Get("results").MustArray() {
|
||||
// fmt.Println(i, v)
|
||||
// }
|
||||
func (j *Json) MustArray(args ...[]interface{}) []interface{} {
|
||||
var def []interface{}
|
||||
func (j *Json) MustArray(args ...[]any) []any {
|
||||
var def []any
|
||||
|
||||
switch len(args) {
|
||||
case 0:
|
||||
@ -352,15 +352,15 @@ func (j *Json) MustArray(args ...[]interface{}) []interface{} {
|
||||
return def
|
||||
}
|
||||
|
||||
// MustMap guarantees the return of a `map[string]interface{}` (with optional default)
|
||||
// MustMap guarantees the return of a `map[string]any` (with optional default)
|
||||
//
|
||||
// useful when you want to iterate over map values in a succinct manner:
|
||||
//
|
||||
// for k, v := range js.Get("dictionary").MustMap() {
|
||||
// fmt.Println(k, v)
|
||||
// }
|
||||
func (j *Json) MustMap(args ...map[string]interface{}) map[string]interface{} {
|
||||
var def map[string]interface{}
|
||||
func (j *Json) MustMap(args ...map[string]any) map[string]any {
|
||||
var def map[string]any
|
||||
|
||||
switch len(args) {
|
||||
case 0:
|
||||
@ -549,13 +549,13 @@ func (j *Json) MustUint64(args ...uint64) uint64 {
|
||||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaller.
|
||||
func (j *Json) MarshalYAML() (interface{}, error) {
|
||||
func (j *Json) MarshalYAML() (any, error) {
|
||||
return j.data, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaller.
|
||||
func (j *Json) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var data interface{}
|
||||
func (j *Json) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var data any
|
||||
if err := unmarshal(&data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ func TestSimplejson(t *testing.T) {
|
||||
ms2 := js.Get("test").Get("missing_string").MustString("fyea")
|
||||
assert.Equal(t, "fyea", ms2)
|
||||
|
||||
ma2 := js.Get("test").Get("missing_array").MustArray([]interface{}{"1", 2, "3"})
|
||||
assert.Equal(t, ma2, []interface{}{"1", 2, "3"})
|
||||
ma2 := js.Get("test").Get("missing_array").MustArray([]any{"1", 2, "3"})
|
||||
assert.Equal(t, ma2, []any{"1", 2, "3"})
|
||||
|
||||
msa := js.Get("test").Get("string_array").MustStringArray()
|
||||
assert.Equal(t, msa[0], "asdf")
|
||||
@ -102,8 +102,8 @@ func TestSimplejson(t *testing.T) {
|
||||
msa3 := js.Get("test").Get("missing_array").MustStringArray([]string{"1", "2", "3"})
|
||||
assert.Equal(t, msa3, []string{"1", "2", "3"})
|
||||
|
||||
mm2 := js.Get("test").Get("missing_map").MustMap(map[string]interface{}{"found": false})
|
||||
assert.Equal(t, mm2, map[string]interface{}{"found": false})
|
||||
mm2 := js.Get("test").Get("missing_map").MustMap(map[string]any{"found": false})
|
||||
assert.Equal(t, mm2, map[string]any{"found": false})
|
||||
|
||||
strs, err := js.Get("test").Get("string_array").StringArray()
|
||||
assert.Equal(t, err, nil)
|
||||
@ -207,7 +207,7 @@ func TestSetPathNoPath(t *testing.T) {
|
||||
f := js.GetPath("some_number").MustFloat64(99.0)
|
||||
assert.Equal(t, f, 1.0)
|
||||
|
||||
js.SetPath([]string{}, map[string]interface{}{"foo": "bar"})
|
||||
js.SetPath([]string{}, map[string]any{"foo": "bar"})
|
||||
|
||||
s, err := js.GetPath("foo").String()
|
||||
assert.Equal(t, nil, err)
|
||||
|
@ -272,11 +272,11 @@ type ConditionQueryJSON struct {
|
||||
|
||||
type ConditionReducerJSON struct {
|
||||
Type string `json:"type"`
|
||||
// Params []interface{} `json:"params"` (Unused)
|
||||
// Params []any `json:"params"` (Unused)
|
||||
}
|
||||
|
||||
// UnmarshalConditionsCmd creates a new ConditionsCmd.
|
||||
func UnmarshalConditionsCmd(rawQuery map[string]interface{}, refID string) (*ConditionsCmd, error) {
|
||||
func UnmarshalConditionsCmd(rawQuery map[string]any, refID string) (*ConditionsCmd, error) {
|
||||
jsonFromM, err := json.Marshal(rawQuery["conditions"])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to remarshal classic condition body: %w", err)
|
||||
|
@ -695,7 +695,7 @@ func TestUnmarshalConditionsCmd(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var rq map[string]interface{}
|
||||
var rq map[string]any
|
||||
|
||||
err := json.Unmarshal([]byte(tt.rawJSON), &rq)
|
||||
require.NoError(t, err)
|
||||
|
@ -123,7 +123,7 @@ func UnmarshalReduceCommand(rn *rawNode) (*ReduceCommand, error) {
|
||||
settings, ok := rn.Query["settings"]
|
||||
if ok {
|
||||
switch s := settings.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
mode, ok := s["mode"]
|
||||
if ok && mode != "" {
|
||||
switch mode {
|
||||
|
@ -75,7 +75,7 @@ func Test_UnmarshalReduceCommand_Settings(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
q := fmt.Sprintf(`{ "expression" : "$A", "reducer": "sum"%s }`, test.querySettings)
|
||||
var qmap = make(map[string]interface{})
|
||||
var qmap = make(map[string]any)
|
||||
require.NoError(t, json.Unmarshal([]byte(q), &qmap))
|
||||
|
||||
cmd, err := UnmarshalReduceCommand(&rawNode{
|
||||
|
@ -16,7 +16,7 @@ var ConversionError = errutil.BadRequest("sse.readDataError").MustTemplate(
|
||||
func MakeConversionError(refID string, err error) error {
|
||||
data := errutil.TemplateData{
|
||||
// Conversion errors should only have meta information in errors
|
||||
Public: map[string]interface{}{
|
||||
Public: map[string]any{
|
||||
"refId": refID,
|
||||
"error": err.Error(),
|
||||
},
|
||||
@ -42,7 +42,7 @@ func MakeQueryError(refID, datasourceUID string, err error) error {
|
||||
}
|
||||
|
||||
data := errutil.TemplateData{
|
||||
Public: map[string]interface{}{
|
||||
Public: map[string]any{
|
||||
"refId": refID,
|
||||
"datasourceUID": datasourceUID,
|
||||
"error": pErr.Error(),
|
||||
|
@ -169,7 +169,7 @@ func (s *Service) buildGraph(req *Request) (*simple.DirectedGraph, error) {
|
||||
return nil, fmt.Errorf("missing datasource uid in query with refId %v", query.RefID)
|
||||
}
|
||||
|
||||
rawQueryProp := make(map[string]interface{})
|
||||
rawQueryProp := make(map[string]any)
|
||||
queryBytes, err := query.JSON.MarshalJSON()
|
||||
|
||||
if err != nil {
|
||||
|
@ -560,7 +560,7 @@ func (e *State) walkFunc(node *parse.FuncNode) (Results, error) {
|
||||
var err error
|
||||
var in []reflect.Value
|
||||
for _, a := range node.Args {
|
||||
var v interface{}
|
||||
var v any
|
||||
switch t := a.(type) {
|
||||
case *parse.StringNode:
|
||||
v = t.Text
|
||||
|
@ -138,7 +138,7 @@ func (l *lexer) lineNumber() int {
|
||||
|
||||
// errorf returns an error token and terminates the scan by passing
|
||||
// back a nil pointer that will be the next state, terminating l.nextItem.
|
||||
func (l *lexer) errorf(format string, args ...interface{}) stateFn {
|
||||
func (l *lexer) errorf(format string, args ...any) stateFn {
|
||||
l.items <- item{itemError, l.start, fmt.Sprintf(format, args...)}
|
||||
return nil
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ func NewSeriesFromRef(refID string, s timeseries.MetricRef) (Series, error) {
|
||||
func (s Series) Type() parse.ReturnType { return parse.TypeSeriesSet }
|
||||
|
||||
// Value returns the actual value allows it to fulfill the Value interface.
|
||||
func (s Series) Value() interface{} { return &s }
|
||||
func (s Series) Value() any { return &s }
|
||||
|
||||
func (s Series) GetLabels() data.Labels { return s.Frame.Fields[seriesTypeValIdx].Labels }
|
||||
|
||||
@ -189,11 +189,11 @@ func (s Series) SetLabels(ls data.Labels) { s.Frame.Fields[seriesTypeValIdx].Lab
|
||||
|
||||
func (s Series) GetName() string { return s.Frame.Fields[seriesTypeValIdx].Name }
|
||||
|
||||
func (s Series) GetMeta() interface{} {
|
||||
func (s Series) GetMeta() any {
|
||||
return s.Frame.Meta.Custom
|
||||
}
|
||||
|
||||
func (s Series) SetMeta(v interface{}) {
|
||||
func (s Series) SetMeta(v any) {
|
||||
m := s.Frame.Meta
|
||||
if m == nil {
|
||||
m = &data.FrameMeta{}
|
||||
|
@ -29,11 +29,11 @@ func (vals Values) AsDataFrames(refID string) []*data.Frame {
|
||||
// all Value implementations should be a *data.Frame
|
||||
type Value interface {
|
||||
Type() parse.ReturnType
|
||||
Value() interface{}
|
||||
Value() any
|
||||
GetLabels() data.Labels
|
||||
SetLabels(data.Labels)
|
||||
GetMeta() interface{}
|
||||
SetMeta(interface{})
|
||||
GetMeta() any
|
||||
SetMeta(any)
|
||||
AsDataFrame() *data.Frame
|
||||
AddNotice(notice data.Notice)
|
||||
}
|
||||
@ -47,17 +47,17 @@ type Scalar struct{ Frame *data.Frame }
|
||||
func (s Scalar) Type() parse.ReturnType { return parse.TypeScalar }
|
||||
|
||||
// Value returns the actual value allows it to fulfill the Value interface.
|
||||
func (s Scalar) Value() interface{} { return s }
|
||||
func (s Scalar) Value() any { return s }
|
||||
|
||||
func (s Scalar) GetLabels() data.Labels { return nil }
|
||||
|
||||
func (s Scalar) SetLabels(ls data.Labels) {}
|
||||
|
||||
func (s Scalar) GetMeta() interface{} {
|
||||
func (s Scalar) GetMeta() any {
|
||||
return s.Frame.Meta.Custom
|
||||
}
|
||||
|
||||
func (s Scalar) SetMeta(v interface{}) {
|
||||
func (s Scalar) SetMeta(v any) {
|
||||
m := s.Frame.Meta
|
||||
if m == nil {
|
||||
m = &data.FrameMeta{}
|
||||
@ -105,7 +105,7 @@ type Number struct{ Frame *data.Frame }
|
||||
func (n Number) Type() parse.ReturnType { return parse.TypeNumberSet }
|
||||
|
||||
// Value returns the actual value allows it to fulfill the Value interface.
|
||||
func (n Number) Value() interface{} { return &n }
|
||||
func (n Number) Value() any { return &n }
|
||||
|
||||
func (n Number) GetLabels() data.Labels { return n.Frame.Fields[0].Labels }
|
||||
|
||||
@ -154,11 +154,11 @@ func NumberFromRef(refID string, nr numeric.MetricRef) (Number, error) {
|
||||
return Number{frame}, nil
|
||||
}
|
||||
|
||||
func (n Number) GetMeta() interface{} {
|
||||
func (n Number) GetMeta() any {
|
||||
return n.Frame.Meta.Custom
|
||||
}
|
||||
|
||||
func (n Number) SetMeta(v interface{}) {
|
||||
func (n Number) SetMeta(v any) {
|
||||
m := n.Frame.Meta
|
||||
if m == nil {
|
||||
m = &data.FrameMeta{}
|
||||
@ -203,17 +203,17 @@ type NoData struct{ Frame *data.Frame }
|
||||
func (s NoData) Type() parse.ReturnType { return parse.TypeNoData }
|
||||
|
||||
// Value returns the actual value allows it to fulfill the Value interface.
|
||||
func (s NoData) Value() interface{} { return s }
|
||||
func (s NoData) Value() any { return s }
|
||||
|
||||
func (s NoData) GetLabels() data.Labels { return nil }
|
||||
|
||||
func (s NoData) SetLabels(ls data.Labels) {}
|
||||
|
||||
func (s NoData) GetMeta() interface{} {
|
||||
func (s NoData) GetMeta() any {
|
||||
return s.Frame.Meta.Custom
|
||||
}
|
||||
|
||||
func (s NoData) SetMeta(v interface{}) {
|
||||
func (s NoData) SetMeta(v any) {
|
||||
m := s.Frame.Meta
|
||||
if m == nil {
|
||||
m = &data.FrameMeta{}
|
||||
|
@ -20,11 +20,11 @@ type OutlierCommandConfiguration struct {
|
||||
|
||||
// If Query is empty it should be contained in a datasource specific format
|
||||
// inside of QueryParms.
|
||||
Query string `json:"query,omitempty"`
|
||||
QueryParams map[string]interface{} `json:"query_params,omitempty"`
|
||||
Query string `json:"query,omitempty"`
|
||||
QueryParams map[string]any `json:"query_params,omitempty"`
|
||||
|
||||
Algorithm map[string]interface{} `json:"algorithm"`
|
||||
ResponseType string `json:"response_type"`
|
||||
Algorithm map[string]any `json:"algorithm"`
|
||||
ResponseType string `json:"response_type"`
|
||||
}
|
||||
|
||||
// outlierAttributes is outlier command configuration that is sent to Machine learning API
|
||||
|
@ -20,14 +20,14 @@ func TestOutlierExec(t *testing.T) {
|
||||
config: OutlierCommandConfiguration{
|
||||
DatasourceType: "prometheus",
|
||||
DatasourceUID: "a4ce599c-4c93-44b9-be5b-76385b8c01be",
|
||||
QueryParams: map[string]interface{}{
|
||||
QueryParams: map[string]any{
|
||||
"expr": "go_goroutines{}",
|
||||
"range": true,
|
||||
"refId": "A",
|
||||
},
|
||||
Algorithm: map[string]interface{}{
|
||||
Algorithm: map[string]any{
|
||||
"name": "dbscan",
|
||||
"config": map[string]interface{}{
|
||||
"config": map[string]any{
|
||||
"epsilon": 7.667,
|
||||
},
|
||||
"sensitivity": 0.83,
|
||||
|
@ -35,7 +35,7 @@ type baseNode struct {
|
||||
|
||||
type rawNode struct {
|
||||
RefID string `json:"refId"`
|
||||
Query map[string]interface{}
|
||||
Query map[string]any
|
||||
QueryRaw []byte
|
||||
QueryType string
|
||||
TimeRange TimeRange
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
type fakePluginContextProvider struct {
|
||||
recordings []struct {
|
||||
method string
|
||||
params []interface{}
|
||||
params []any
|
||||
}
|
||||
result map[string]*backend.AppInstanceSettings
|
||||
errorResult error
|
||||
@ -23,8 +23,8 @@ var _ pluginContextProvider = &fakePluginContextProvider{}
|
||||
func (f *fakePluginContextProvider) Get(_ context.Context, pluginID string, user identity.Requester, orgID int64) (backend.PluginContext, error) {
|
||||
f.recordings = append(f.recordings, struct {
|
||||
method string
|
||||
params []interface{}
|
||||
}{method: "Get", params: []interface{}{pluginID, user, orgID}})
|
||||
params []any
|
||||
}{method: "Get", params: []any{pluginID, user, orgID}})
|
||||
if f.errorResult != nil {
|
||||
return backend.PluginContext{}, f.errorResult
|
||||
}
|
||||
@ -48,8 +48,8 @@ func (f *fakePluginContextProvider) Get(_ context.Context, pluginID string, user
|
||||
func (f *fakePluginContextProvider) GetWithDataSource(ctx context.Context, pluginID string, user identity.Requester, ds *datasources.DataSource) (backend.PluginContext, error) {
|
||||
f.recordings = append(f.recordings, struct {
|
||||
method string
|
||||
params []interface{}
|
||||
}{method: "GetWithDataSource", params: []interface{}{pluginID, user, ds}})
|
||||
params []any
|
||||
}{method: "GetWithDataSource", params: []any{pluginID, user, ds}})
|
||||
|
||||
if f.errorResult != nil {
|
||||
return backend.PluginContext{}, f.errorResult
|
||||
|
@ -149,7 +149,7 @@ func TestUnmarshalThresholdCommand(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
q := []byte(tc.query)
|
||||
|
||||
var qmap = make(map[string]interface{})
|
||||
var qmap = make(map[string]any)
|
||||
require.NoError(t, json.Unmarshal(q, &qmap))
|
||||
|
||||
cmd, err := UnmarshalThresholdCommand(&rawNode{
|
||||
|
@ -19,16 +19,16 @@ type SQLBuilder struct {
|
||||
cfg *setting.Cfg
|
||||
features featuremgmt.FeatureToggles
|
||||
sql bytes.Buffer
|
||||
params []interface{}
|
||||
params []any
|
||||
leftJoin string
|
||||
recQry string
|
||||
recQryParams []interface{}
|
||||
recQryParams []any
|
||||
recursiveQueriesAreSupported bool
|
||||
|
||||
dialect migrator.Dialect
|
||||
}
|
||||
|
||||
func (sb *SQLBuilder) Write(sql string, params ...interface{}) {
|
||||
func (sb *SQLBuilder) Write(sql string, params ...any) {
|
||||
sb.sql.WriteString(sql)
|
||||
|
||||
if len(params) > 0 {
|
||||
@ -50,7 +50,7 @@ func (sb *SQLBuilder) GetSQLString() string {
|
||||
return bf.String()
|
||||
}
|
||||
|
||||
func (sb *SQLBuilder) GetParams() []interface{} {
|
||||
func (sb *SQLBuilder) GetParams() []any {
|
||||
if len(sb.recQryParams) == 0 {
|
||||
return sb.params
|
||||
}
|
||||
@ -59,16 +59,16 @@ func (sb *SQLBuilder) GetParams() []interface{} {
|
||||
return sb.params
|
||||
}
|
||||
|
||||
func (sb *SQLBuilder) AddParams(params ...interface{}) {
|
||||
func (sb *SQLBuilder) AddParams(params ...any) {
|
||||
sb.params = append(sb.params, params...)
|
||||
}
|
||||
|
||||
func (sb *SQLBuilder) WriteDashboardPermissionFilter(user *user.SignedInUser, permission dashboards.PermissionType, queryType string) {
|
||||
var (
|
||||
sql string
|
||||
params []interface{}
|
||||
params []any
|
||||
recQry string
|
||||
recQryParams []interface{}
|
||||
recQryParams []any
|
||||
leftJoin string
|
||||
)
|
||||
|
||||
|
@ -516,7 +516,7 @@ func (s dbFileStorage) DeleteFolder(ctx context.Context, folderPath string, opti
|
||||
}
|
||||
|
||||
err := s.db.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
||||
var rawHashes []interface{}
|
||||
var rawHashes []any
|
||||
|
||||
// xorm does not support `.Delete()` with `.Join()`, so we first have to retrieve all path_hashes and then use them to filter `file_meta` table
|
||||
err := sess.Table("file").
|
||||
@ -547,7 +547,7 @@ func (s dbFileStorage) DeleteFolder(ctx context.Context, folderPath string, opti
|
||||
return fmt.Errorf("force folder delete: unauthorized access for path %s", lowerFolderPath)
|
||||
}
|
||||
|
||||
var hashes []interface{}
|
||||
var hashes []any
|
||||
for _, hash := range rawHashes {
|
||||
if hashString, ok := hash.(string); ok {
|
||||
hashes = append(hashes, hashString)
|
||||
|
@ -21,7 +21,7 @@ const (
|
||||
type fsTestCase struct {
|
||||
name string
|
||||
skip *bool
|
||||
steps []interface{}
|
||||
steps []any
|
||||
}
|
||||
|
||||
func runTestCase(t *testing.T, testCase fsTestCase, ctx context.Context, filestorage FileStorage) {
|
||||
@ -186,7 +186,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
return []fsTestCase{
|
||||
{
|
||||
name: "listing files",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/folder2/file.jpg",
|
||||
@ -210,7 +210,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: true}},
|
||||
list: checks(listSize(3), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
checks(fPath("/folder1/file-inner2.jpg"), fProperties(map[string]string{})),
|
||||
checks(fPath("/folder1/folder2/file.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
@ -219,7 +219,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}},
|
||||
list: checks(listSize(4), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
checks(fPath("/folder1/file-inner2.jpg"), fProperties(map[string]string{})),
|
||||
checks(fPath("/folder1/folder2"), fProperties(map[string]string{}), fMimeType(DirectoryMimeType)),
|
||||
@ -229,19 +229,19 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: false}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: false, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1"), fProperties(map[string]string{}), fMimeType(DirectoryMimeType)),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: false}},
|
||||
list: checks(listSize(2), listHasMore(false), listLastPath("/folder1/file-inner2.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
checks(fPath("/folder1/file-inner2.jpg"), fProperties(map[string]string{})),
|
||||
},
|
||||
@ -249,7 +249,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: false, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(3), listHasMore(false), listLastPath("/folder1/folder2")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
checks(fPath("/folder1/file-inner2.jpg"), fProperties(map[string]string{})),
|
||||
checks(fPath("/folder1/folder2"), fProperties(map[string]string{}), fMimeType(DirectoryMimeType)),
|
||||
@ -258,32 +258,32 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2", options: &ListOptions{Recursive: false}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2/file.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2", options: &ListOptions{Recursive: false, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2/file.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2", options: &ListOptions{Recursive: false}, paging: &Paging{After: "/folder1/folder2/file.jpg"}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2", options: &ListOptions{Recursive: false, WithFolders: true, WithFiles: true}, paging: &Paging{After: "/folder1/folder2/file.jpg"}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "path passed to listing files is a folder path, not a prefix",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/ab/a.jpg",
|
||||
@ -311,7 +311,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/ab", options: &ListOptions{Recursive: true}},
|
||||
list: checks(listSize(2), listHasMore(false), listLastPath("/ab/a/a.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/ab/a.jpg")),
|
||||
checks(fPath("/ab/a/a.jpg")),
|
||||
},
|
||||
@ -319,7 +319,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/ab", options: &ListOptions{Recursive: true, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(3), listHasMore(false), listLastPath("/ab/a/a.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/ab/a.jpg")),
|
||||
checks(fPath("/ab/a"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/ab/a/a.jpg")),
|
||||
@ -329,7 +329,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "listing files with path to a file",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/folder2/file.jpg",
|
||||
@ -370,35 +370,35 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2/file.jpg", options: &ListOptions{Recursive: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2/file.jpg"), fName("file.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2/file.jpg", options: &ListOptions{Recursive: true, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/folder2/file.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2/file.jpg"), fName("file.jpg"), fProperties(map[string]string{"prop1": "val1", "prop2": "val"})),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/file-inner.jpg", options: &ListOptions{Recursive: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/file-inner.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fName("file-inner.jpg"), fProperties(map[string]string{"prop1": "val1"})),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/dashboards/dashboards/file-inner.jpg", options: &ListOptions{Recursive: true, WithFiles: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/dashboards/dashboards/file-inner.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/dashboards/dashboards/file-inner.jpg"), fName("file-inner.jpg")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/file-inner.jpg", options: &ListOptions{Recursive: true, WithFolders: true, WithFiles: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/file-inner.jpg")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/file-inner.jpg"), fName("file-inner.jpg"), fProperties(map[string]string{"prop1": "val1"})),
|
||||
},
|
||||
},
|
||||
@ -406,7 +406,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "listing files with prefix filter",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/folder2/file.jpg",
|
||||
@ -426,19 +426,19 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true, Filter: NewPathFilter([]string{"/folder2"}, nil, nil, nil)}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: true, Filter: NewPathFilter([]string{"/folder1/folder"}, nil, nil, nil)}},
|
||||
list: checks(listSize(1), listHasMore(false)),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2/file.jpg")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true, Filter: NewPathFilter([]string{"/folder1/folder"}, nil, nil, nil)}},
|
||||
list: checks(listSize(2), listHasMore(false)),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2"), fMimeType("directory")),
|
||||
checks(fPath("/folder1/folder2/file.jpg")),
|
||||
},
|
||||
@ -447,7 +447,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "listing files with pagination",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/a",
|
||||
@ -469,7 +469,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true}, paging: &Paging{First: 2, After: ""}},
|
||||
list: checks(listSize(2), listHasMore(true), listLastPath("/folder1/b")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/a")),
|
||||
checks(fPath("/folder1/b")),
|
||||
},
|
||||
@ -477,7 +477,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 2, After: ""}},
|
||||
list: checks(listSize(2), listHasMore(true), listLastPath("/folder1/a")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folder1/a")),
|
||||
},
|
||||
@ -485,49 +485,49 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 1, After: "/folder1"}},
|
||||
list: checks(listSize(1), listHasMore(true), listLastPath("/folder1/a")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/a")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true}, paging: &Paging{First: 1, After: "/folder1/a"}},
|
||||
list: checks(listSize(1), listHasMore(true), listLastPath("/folder1/b")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/b")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 1, After: "/folder1/a"}},
|
||||
list: checks(listSize(1), listHasMore(true), listLastPath("/folder1/b")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/b")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true}, paging: &Paging{First: 1, After: "/folder1/b"}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder2/c")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder2/c")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 1, After: "/folder1/b"}},
|
||||
list: checks(listSize(1), listHasMore(true), listLastPath("/folder2")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder2"), fMimeType(DirectoryMimeType)),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 1, After: "/folder2"}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder2/c")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder2/c")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true}, paging: &Paging{First: 5, After: ""}},
|
||||
list: checks(listSize(3), listHasMore(false), listLastPath("/folder2/c")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/a")),
|
||||
checks(fPath("/folder1/b")),
|
||||
checks(fPath("/folder2/c")),
|
||||
@ -536,7 +536,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: true, WithFolders: true}, paging: &Paging{First: 5, After: ""}},
|
||||
list: checks(listSize(5), listHasMore(false), listLastPath("/folder2/c")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folder1/a")),
|
||||
checks(fPath("/folder1/b")),
|
||||
@ -569,7 +569,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
return []fsTestCase{
|
||||
{
|
||||
name: "listing folders",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/folder2/file.jpg",
|
||||
@ -596,7 +596,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder1")),
|
||||
checks(fPath("/folder1/folder2")),
|
||||
checks(fPath("/folderA")),
|
||||
@ -608,7 +608,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: true, WithFiles: false, WithFolders: true}},
|
||||
list: checks(listSize(6), listHasMore(false), listLastPath("/folderX/folderZ")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folder1/folder2"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folderA"), fMimeType(DirectoryMimeType)),
|
||||
@ -621,7 +621,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "listing folders non recursively",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder1/folder2/file.jpg",
|
||||
@ -648,34 +648,34 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/folder1", options: &ListOptions{Recursive: false}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder1/folder2")),
|
||||
},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1", options: &ListOptions{Recursive: false, WithFiles: false, WithFolders: true}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/folder1/folder2")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1/folder2"), fMimeType(DirectoryMimeType)),
|
||||
},
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/folderZ", options: &ListOptions{Recursive: false}},
|
||||
checks: [][]interface{}{},
|
||||
checks: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folderZ", options: &ListOptions{Recursive: false, WithFiles: false, WithFolders: true}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/folder1/folder2", options: &ListOptions{Recursive: false, WithFiles: false, WithFolders: true}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: false}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder1")),
|
||||
checks(fPath("/folderA")),
|
||||
checks(fPath("/folderX")),
|
||||
@ -684,7 +684,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/", options: &ListOptions{Recursive: false, WithFiles: false, WithFolders: true}},
|
||||
list: checks(listSize(3), listHasMore(false), listLastPath("/folderX")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/folder1"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folderA"), fMimeType(DirectoryMimeType)),
|
||||
checks(fPath("/folderX"), fMimeType(DirectoryMimeType)),
|
||||
@ -699,7 +699,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
return []fsTestCase{
|
||||
{
|
||||
name: "getting a non-existent file",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
queryGet{
|
||||
input: queryGetInput{
|
||||
path: "/folder/a.png",
|
||||
@ -709,7 +709,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "inserting a file",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/folder/a.png",
|
||||
@ -734,7 +734,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "preserved original path/name casing when getting a file",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/Folder/A.png",
|
||||
@ -754,7 +754,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "modifying file metadata",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/a.png",
|
||||
@ -790,7 +790,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "modifying file metadata preserves original path casing",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/aB.png",
|
||||
@ -827,7 +827,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "modifying file contents",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/FILE.png",
|
||||
@ -881,7 +881,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "deleting a file",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/FILE.png",
|
||||
@ -924,7 +924,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "deleting a non-existent file should be no-op",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdDelete{
|
||||
path: "/file.png",
|
||||
},
|
||||
@ -937,7 +937,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
return []fsTestCase{
|
||||
{
|
||||
name: "recreating a folder after it was already created via upserting a file is a no-op",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/aB/cD/eF/file.jpg",
|
||||
@ -948,7 +948,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
checks(fPath("/aB/cD")),
|
||||
checks(fPath("/aB/cD/eF")),
|
||||
@ -961,7 +961,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
checks(fPath("/aB/cD")),
|
||||
checks(fPath("/aB/cD/eF")),
|
||||
@ -974,7 +974,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
checks(fPath("/aB/cD")),
|
||||
checks(fPath("/aB/cD/eF")),
|
||||
@ -985,7 +985,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "creating a folder with the same name or same name but different casing is a no-op",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/aB",
|
||||
},
|
||||
@ -999,7 +999,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
},
|
||||
},
|
||||
@ -1010,7 +1010,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
},
|
||||
},
|
||||
@ -1018,7 +1018,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "creating folder is recursive",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/a/b/c",
|
||||
},
|
||||
@ -1026,7 +1026,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/a")),
|
||||
checks(fPath("/a/b")),
|
||||
checks(fPath("/a/b/c")),
|
||||
@ -1036,7 +1036,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "deleting a leaf directory does not delete parent directories even if they are empty - folders created directly",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/a/b/c",
|
||||
},
|
||||
@ -1047,7 +1047,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/a")),
|
||||
checks(fPath("/a/b")),
|
||||
},
|
||||
@ -1056,7 +1056,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "deleting a leaf directory does not delete parent directories even if they are empty - folders created via file upsert",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/a/b/c/file.jpg",
|
||||
@ -1067,7 +1067,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/a")),
|
||||
checks(fPath("/a/b")),
|
||||
checks(fPath("/a/b/c")),
|
||||
@ -1081,7 +1081,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/a")),
|
||||
checks(fPath("/a/b")),
|
||||
checks(fPath("/a/b/c")),
|
||||
@ -1094,7 +1094,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/a")),
|
||||
checks(fPath("/a/b")),
|
||||
},
|
||||
@ -1103,7 +1103,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "folders preserve their original casing",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/aB/cD/e",
|
||||
},
|
||||
@ -1114,7 +1114,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
input: queryListFoldersInput{
|
||||
path: "/",
|
||||
},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/aB")),
|
||||
checks(fPath("/aB/cD")),
|
||||
checks(fPath("/aB/cD/e")),
|
||||
@ -1125,13 +1125,13 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "folders can't be deleted through the `delete` method",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder")),
|
||||
checks(fPath("/folder/dashboards")),
|
||||
checks(fPath("/folder/dashboards/myNewFolder")),
|
||||
@ -1142,7 +1142,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder")),
|
||||
checks(fPath("/folder/dashboards")),
|
||||
checks(fPath("/folder/dashboards/myNewFolder")),
|
||||
@ -1152,7 +1152,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "folders can not be retrieved through the `get` method",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
@ -1165,7 +1165,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "should not be able to delete folders with files",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
@ -1179,12 +1179,12 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
error: &cmdErrorOutput{
|
||||
message: "folder %s is not empty - cant remove it",
|
||||
args: []interface{}{"/folder/dashboards/myNewFolder"},
|
||||
args: []any{"/folder/dashboards/myNewFolder"},
|
||||
},
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder")),
|
||||
checks(fPath("/folder/dashboards")),
|
||||
checks(fPath("/folder/dashboards/myNewFolder")),
|
||||
@ -1202,7 +1202,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "should be able to delete folders with files if using force",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
@ -1220,7 +1220,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder")),
|
||||
checks(fPath("/folder/dashboards")),
|
||||
},
|
||||
@ -1234,7 +1234,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "should be able to delete root folder with force",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
@ -1252,7 +1252,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{},
|
||||
checks: [][]any{},
|
||||
},
|
||||
queryGet{
|
||||
input: queryGetInput{
|
||||
@ -1263,7 +1263,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "should not be able to delete a folder unless have access to all nested files",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdCreateFolder{
|
||||
path: "/folder/dashboards/myNewFolder",
|
||||
},
|
||||
@ -1287,12 +1287,12 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
},
|
||||
error: &cmdErrorOutput{
|
||||
message: "force folder delete: unauthorized access for path %s",
|
||||
args: []interface{}{"/"},
|
||||
args: []any{"/"},
|
||||
},
|
||||
},
|
||||
queryListFolders{
|
||||
input: queryListFoldersInput{path: "/", options: &ListOptions{Recursive: true}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
checks(fPath("/folder")),
|
||||
checks(fPath("/folder/dashboards")),
|
||||
checks(fPath("/folder/dashboards/abc")),
|
||||
@ -1330,7 +1330,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
return []fsTestCase{
|
||||
{
|
||||
name: "catch-all test - TODO: split into multiple",
|
||||
steps: []interface{}{
|
||||
steps: []any{
|
||||
cmdUpsert{
|
||||
cmd: UpsertFileCommand{
|
||||
Path: "/s3/folder/dashboard.json",
|
||||
@ -1393,7 +1393,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
list: checks(listSize(5), listHasMore(false), listLastPath("/s3/folder/dashboard.json")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
// /gitA/dashboard.json is not explicitly allowed
|
||||
checks(fPath("/gitA/dashboard2.json")), // explicitly allowed by allowedPath
|
||||
checks(fPath("/gitB/nested/dashboard.json")), // allowed by '/gitB/' prefix
|
||||
@ -1411,7 +1411,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
WithFolders: true,
|
||||
}},
|
||||
list: checks(listSize(10), listHasMore(false), listLastPath("/s3/folder/dashboard.json")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
// /gitA/dashboard.json is not explicitly allowed
|
||||
checks(fPath("/gitA/dashboard2.json")), // explicitly allowed by allowedPath
|
||||
checks(fPath("/gitB")), // allowed by '/gitB/' prefix
|
||||
@ -1433,7 +1433,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Recursive: true,
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
checks: [][]interface{}{
|
||||
checks: [][]any{
|
||||
// /gitA is missing due to the lack of explicit allow
|
||||
checks(fPath("/gitB")), // allowed by '/gitB/' prefix
|
||||
checks(fPath("/gitB/nested")), // allowed by '/gitB/' prefix
|
||||
@ -1451,7 +1451,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/gitA/dashboard2.json")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/gitA/dashboard2.json")),
|
||||
},
|
||||
},
|
||||
@ -1460,7 +1460,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Recursive: false,
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
checks: [][]interface{}{},
|
||||
checks: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/gitC", options: &ListOptions{
|
||||
@ -1468,7 +1468,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
list: checks(listSize(0), listHasMore(false), listLastPath("")),
|
||||
files: [][]interface{}{},
|
||||
files: [][]any{},
|
||||
},
|
||||
queryListFiles{
|
||||
input: queryListFilesInput{path: "/gitC/nestedC", options: &ListOptions{
|
||||
@ -1476,7 +1476,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
list: checks(listSize(1), listHasMore(false), listLastPath("/gitC/nestedC/dashboardC.json")),
|
||||
files: [][]interface{}{
|
||||
files: [][]any{
|
||||
checks(fPath("/gitC/nestedC/dashboardC.json")),
|
||||
},
|
||||
},
|
||||
@ -1485,7 +1485,7 @@ func TestIntegrationFsStorage(t *testing.T) {
|
||||
Recursive: false,
|
||||
Filter: pathFilters,
|
||||
}},
|
||||
checks: [][]interface{}{},
|
||||
checks: [][]any{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ type GRN struct {
|
||||
ResourceIdentifier string
|
||||
|
||||
// GRN can not be extended
|
||||
_ interface{}
|
||||
_ any
|
||||
}
|
||||
|
||||
// ParseStr attempts to parse a string into a GRN. It returns an error if the
|
||||
|
@ -14,7 +14,7 @@ func newCompositeLogger(loggers ...gokitlog.Logger) *compositeLogger {
|
||||
return &compositeLogger{loggers: loggers}
|
||||
}
|
||||
|
||||
func (l *compositeLogger) Log(keyvals ...interface{}) error {
|
||||
func (l *compositeLogger) Log(keyvals ...any) error {
|
||||
for _, logger := range l.loggers {
|
||||
if err := logger.Log(keyvals...); err != nil {
|
||||
return err
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
)
|
||||
|
||||
func TestCompositeLogger(t *testing.T) {
|
||||
loggedArgs := [][]interface{}{}
|
||||
l := gokitlog.LoggerFunc(func(i ...interface{}) error {
|
||||
loggedArgs := [][]any{}
|
||||
l := gokitlog.LoggerFunc(func(i ...any) error {
|
||||
loggedArgs = append(loggedArgs, i)
|
||||
return nil
|
||||
})
|
||||
|
@ -78,7 +78,7 @@ func NewFileWriter() *FileLogWriter {
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *FileLogWriter) Log(keyvals ...interface{}) error {
|
||||
func (w *FileLogWriter) Log(keyvals ...any) error {
|
||||
return w.logger.Log(keyvals...)
|
||||
}
|
||||
|
||||
|
@ -14,21 +14,21 @@ const (
|
||||
|
||||
type Logger interface {
|
||||
// New returns a new contextual Logger that has this logger's context plus the given context.
|
||||
New(ctx ...interface{}) *ConcreteLogger
|
||||
New(ctx ...any) *ConcreteLogger
|
||||
|
||||
Log(keyvals ...interface{}) error
|
||||
Log(keyvals ...any) error
|
||||
|
||||
// Debug logs a message with debug level and key/value pairs, if any.
|
||||
Debug(msg string, ctx ...interface{})
|
||||
Debug(msg string, ctx ...any)
|
||||
|
||||
// Info logs a message with info level and key/value pairs, if any.
|
||||
Info(msg string, ctx ...interface{})
|
||||
Info(msg string, ctx ...any)
|
||||
|
||||
// Warn logs a message with warning level and key/value pairs, if any.
|
||||
Warn(msg string, ctx ...interface{})
|
||||
Warn(msg string, ctx ...any)
|
||||
|
||||
// Error logs a message with error level and key/value pairs, if any.
|
||||
Error(msg string, ctx ...interface{})
|
||||
Error(msg string, ctx ...any)
|
||||
|
||||
// FromContext returns a new contextual Logger that has this logger's context plus the given context.
|
||||
FromContext(ctx context.Context) Logger
|
||||
|
@ -102,7 +102,7 @@ func (lm *logManager) initialize(loggers []logWithFilters) {
|
||||
}
|
||||
}
|
||||
|
||||
func (lm *logManager) New(ctx ...interface{}) *ConcreteLogger {
|
||||
func (lm *logManager) New(ctx ...any) *ConcreteLogger {
|
||||
if len(ctx) == 0 {
|
||||
return lm.ConcreteLogger
|
||||
}
|
||||
@ -143,15 +143,15 @@ func (lm *logManager) New(ctx ...interface{}) *ConcreteLogger {
|
||||
}
|
||||
|
||||
type ConcreteLogger struct {
|
||||
ctx []interface{}
|
||||
ctx []any
|
||||
gokitlog.SwapLogger
|
||||
}
|
||||
|
||||
func newConcreteLogger(logger gokitlog.Logger, ctx ...interface{}) *ConcreteLogger {
|
||||
func newConcreteLogger(logger gokitlog.Logger, ctx ...any) *ConcreteLogger {
|
||||
var swapLogger gokitlog.SwapLogger
|
||||
|
||||
if len(ctx) == 0 {
|
||||
ctx = []interface{}{}
|
||||
ctx = []any{}
|
||||
swapLogger.Swap(logger)
|
||||
} else {
|
||||
swapLogger.Swap(gokitlog.With(logger, ctx...))
|
||||
@ -167,33 +167,33 @@ func (cl ConcreteLogger) GetLogger() gokitlog.Logger {
|
||||
return &cl.SwapLogger
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) Warn(msg string, args ...interface{}) {
|
||||
func (cl *ConcreteLogger) Warn(msg string, args ...any) {
|
||||
_ = cl.log(msg, level.WarnValue(), args...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) Debug(msg string, args ...interface{}) {
|
||||
func (cl *ConcreteLogger) Debug(msg string, args ...any) {
|
||||
_ = cl.log(msg, level.DebugValue(), args...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) Log(ctx ...interface{}) error {
|
||||
func (cl *ConcreteLogger) Log(ctx ...any) error {
|
||||
logger := gokitlog.With(&cl.SwapLogger, "t", gokitlog.TimestampFormat(now, logTimeFormat))
|
||||
return logger.Log(ctx...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) Error(msg string, args ...interface{}) {
|
||||
func (cl *ConcreteLogger) Error(msg string, args ...any) {
|
||||
_ = cl.log(msg, level.ErrorValue(), args...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) Info(msg string, args ...interface{}) {
|
||||
func (cl *ConcreteLogger) Info(msg string, args ...any) {
|
||||
_ = cl.log(msg, level.InfoValue(), args...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) log(msg string, logLevel level.Value, args ...interface{}) error {
|
||||
return cl.Log(append([]interface{}{level.Key(), logLevel, "msg", msg}, args...)...)
|
||||
func (cl *ConcreteLogger) log(msg string, logLevel level.Value, args ...any) error {
|
||||
return cl.Log(append([]any{level.Key(), logLevel, "msg", msg}, args...)...)
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) FromContext(ctx context.Context) Logger {
|
||||
args := []interface{}{}
|
||||
args := []any{}
|
||||
|
||||
for _, p := range ctxLogProviders {
|
||||
if pArgs, exists := p(ctx); exists {
|
||||
@ -208,7 +208,7 @@ func (cl *ConcreteLogger) FromContext(ctx context.Context) Logger {
|
||||
return cl
|
||||
}
|
||||
|
||||
func (cl *ConcreteLogger) New(ctx ...interface{}) *ConcreteLogger {
|
||||
func (cl *ConcreteLogger) New(ctx ...any) *ConcreteLogger {
|
||||
if len(ctx) == 0 {
|
||||
root.New()
|
||||
}
|
||||
@ -228,12 +228,12 @@ func (cl *ConcreteLogger) New(ctx ...interface{}) *ConcreteLogger {
|
||||
// Example creating a contextual logger:
|
||||
//
|
||||
// contextualLogger := requestLogger.New("username", "user123")
|
||||
func New(ctx ...interface{}) *ConcreteLogger {
|
||||
func New(ctx ...any) *ConcreteLogger {
|
||||
if len(ctx) == 0 {
|
||||
return root.New()
|
||||
}
|
||||
|
||||
ctx = append([]interface{}{"logger"}, ctx...)
|
||||
ctx = append([]any{"logger"}, ctx...)
|
||||
return root.New(ctx...)
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ func NewNopLogger() *ConcreteLogger {
|
||||
return newConcreteLogger(gokitlog.NewNopLogger())
|
||||
}
|
||||
|
||||
func with(ctxLogger *ConcreteLogger, withFunc func(gokitlog.Logger, ...interface{}) gokitlog.Logger, ctx []interface{}) *ConcreteLogger {
|
||||
func with(ctxLogger *ConcreteLogger, withFunc func(gokitlog.Logger, ...any) gokitlog.Logger, ctx []any) *ConcreteLogger {
|
||||
if len(ctx) == 0 {
|
||||
return ctxLogger
|
||||
}
|
||||
@ -252,17 +252,17 @@ func with(ctxLogger *ConcreteLogger, withFunc func(gokitlog.Logger, ...interface
|
||||
}
|
||||
|
||||
// WithPrefix adds context that will be added to the log message
|
||||
func WithPrefix(ctxLogger *ConcreteLogger, ctx ...interface{}) *ConcreteLogger {
|
||||
func WithPrefix(ctxLogger *ConcreteLogger, ctx ...any) *ConcreteLogger {
|
||||
return with(ctxLogger, gokitlog.WithPrefix, ctx)
|
||||
}
|
||||
|
||||
// WithSuffix adds context that will be appended at the end of the log message
|
||||
func WithSuffix(ctxLogger *ConcreteLogger, ctx ...interface{}) *ConcreteLogger {
|
||||
func WithSuffix(ctxLogger *ConcreteLogger, ctx ...any) *ConcreteLogger {
|
||||
return with(ctxLogger, gokitlog.WithSuffix, ctx)
|
||||
}
|
||||
|
||||
// ContextualLogProviderFunc contextual log provider function definition.
|
||||
type ContextualLogProviderFunc func(ctx context.Context) ([]interface{}, bool)
|
||||
type ContextualLogProviderFunc func(ctx context.Context) ([]any, bool)
|
||||
|
||||
// RegisterContextualLogProvider registers a ContextualLogProviderFunc
|
||||
// that will be used to provide context when Logger.FromContext is called.
|
||||
@ -328,7 +328,7 @@ func Stack(skip int) string {
|
||||
|
||||
// StackCaller returns a go-kit Valuer function that returns the stack trace from the place it is called. Argument `skip` allows skipping top n lines from the stack.
|
||||
func StackCaller(skip int) gokitlog.Valuer {
|
||||
return func() interface{} {
|
||||
return func() any {
|
||||
return Stack(skip + 1)
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ func TestNew(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("When initializing root logger should swap loggers as expected", func(t *testing.T) {
|
||||
swappedLoggedArgs := [][]interface{}{}
|
||||
swapLogger := gokitlog.LoggerFunc(func(i ...interface{}) error {
|
||||
swappedLoggedArgs := [][]any{}
|
||||
swapLogger := gokitlog.LoggerFunc(func(i ...any) error {
|
||||
swappedLoggedArgs = append(swappedLoggedArgs, i)
|
||||
return nil
|
||||
})
|
||||
@ -113,8 +113,8 @@ func TestContextualArguments(t *testing.T) {
|
||||
childLoggerCtx := childLogger.FromContext(ctx)
|
||||
childLoggerCtx.Error("hello child")
|
||||
|
||||
RegisterContextualLogProvider(func(ctx context.Context) ([]interface{}, bool) {
|
||||
return []interface{}{"ctxKey", "ctxValue"}, true
|
||||
RegisterContextualLogProvider(func(ctx context.Context) ([]any, bool) {
|
||||
return []any{"ctxKey", "ctxValue"}, true
|
||||
})
|
||||
|
||||
rootLoggerCtx = rootLogger.FromContext(ctx)
|
||||
@ -268,7 +268,7 @@ func TestGetFilters(t *testing.T) {
|
||||
}
|
||||
|
||||
type scenarioContext struct {
|
||||
loggedArgs [][]interface{}
|
||||
loggedArgs [][]any
|
||||
mockedTime time.Time
|
||||
}
|
||||
|
||||
@ -291,11 +291,11 @@ func newLoggerScenario(t testing.TB) *scenarioContext {
|
||||
t.Helper()
|
||||
|
||||
scenario := &scenarioContext{
|
||||
loggedArgs: [][]interface{}{},
|
||||
loggedArgs: [][]any{},
|
||||
mockedTime: time.Now(),
|
||||
}
|
||||
|
||||
l := gokitlog.LoggerFunc(func(i ...interface{}) error {
|
||||
l := gokitlog.LoggerFunc(func(i ...any) error {
|
||||
scenario.loggedArgs = append(scenario.loggedArgs, i)
|
||||
return nil
|
||||
})
|
||||
|
@ -16,50 +16,50 @@ type Fake struct {
|
||||
type Logs struct {
|
||||
Calls int
|
||||
Message string
|
||||
Ctx []interface{}
|
||||
Ctx []any
|
||||
}
|
||||
|
||||
func (f *Fake) New(ctx ...interface{}) *log.ConcreteLogger {
|
||||
func (f *Fake) New(ctx ...any) *log.ConcreteLogger {
|
||||
return log.NewNopLogger()
|
||||
}
|
||||
|
||||
func (f *Fake) Log(keyvals ...interface{}) error {
|
||||
func (f *Fake) Log(keyvals ...any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Fake) Debug(msg string, ctx ...interface{}) {
|
||||
func (f *Fake) Debug(msg string, ctx ...any) {
|
||||
f.DebugLogs.Calls++
|
||||
f.DebugLogs.Message = msg
|
||||
f.DebugLogs.Ctx = ctx
|
||||
}
|
||||
|
||||
func (f *Fake) Info(msg string, ctx ...interface{}) {
|
||||
func (f *Fake) Info(msg string, ctx ...any) {
|
||||
f.InfoLogs.Calls++
|
||||
f.InfoLogs.Message = msg
|
||||
f.InfoLogs.Ctx = ctx
|
||||
}
|
||||
|
||||
func (f *Fake) Warn(msg string, ctx ...interface{}) {
|
||||
func (f *Fake) Warn(msg string, ctx ...any) {
|
||||
f.WarnLogs.Calls++
|
||||
f.WarnLogs.Message = msg
|
||||
f.WarnLogs.Ctx = ctx
|
||||
}
|
||||
|
||||
func (f *Fake) Error(msg string, ctx ...interface{}) {
|
||||
func (f *Fake) Error(msg string, ctx ...any) {
|
||||
f.ErrorLogs.Calls++
|
||||
f.ErrorLogs.Message = msg
|
||||
f.ErrorLogs.Ctx = ctx
|
||||
}
|
||||
|
||||
func (f *Fake) DebugCtx(_ context.Context, msg string, args ...interface{}) {
|
||||
func (f *Fake) DebugCtx(_ context.Context, msg string, args ...any) {
|
||||
f.Debug(msg, args...)
|
||||
}
|
||||
|
||||
func (f *Fake) InfoCtx(_ context.Context, msg string, args ...interface{}) {
|
||||
func (f *Fake) InfoCtx(_ context.Context, msg string, args ...any) {
|
||||
f.Info(msg, args...)
|
||||
}
|
||||
|
||||
func (f *Fake) WarnCtx(_ context.Context, msg string, args ...interface{}) {
|
||||
func (f *Fake) WarnCtx(_ context.Context, msg string, args ...any) {
|
||||
f.Warn(msg, args...)
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ type SysLogHandler struct {
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
var selector = func(keyvals ...interface{}) syslog.Priority {
|
||||
var selector = func(keyvals ...any) syslog.Priority {
|
||||
for i := 0; i < len(keyvals); i += 2 {
|
||||
if keyvals[i] == level.Key() {
|
||||
val := keyvals[i+1]
|
||||
@ -75,7 +75,7 @@ func (sw *SysLogHandler) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sw *SysLogHandler) Log(keyvals ...interface{}) error {
|
||||
func (sw *SysLogHandler) Log(keyvals ...any) error {
|
||||
err := sw.logger.Log(keyvals...)
|
||||
return err
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ func NewSyslog(sec *ini.Section, format Formatedlogger) *SysLogHandler {
|
||||
return &SysLogHandler{}
|
||||
}
|
||||
|
||||
func (sw *SysLogHandler) Log(keyvals ...interface{}) error {
|
||||
func (sw *SysLogHandler) Log(keyvals ...any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ type Bridge struct {
|
||||
// log.Logger from the standard library implements this interface, and it is
|
||||
// easy to implement by custom loggers, if they don't do so already anyway.
|
||||
type Logger interface {
|
||||
Println(v ...interface{})
|
||||
Println(v ...any)
|
||||
}
|
||||
|
||||
// NewBridge returns a pointer to a new Bridge struct.
|
||||
|
@ -15,7 +15,7 @@ type logWrapper struct {
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func (lw *logWrapper) Println(v ...interface{}) {
|
||||
func (lw *logWrapper) Println(v ...any) {
|
||||
lw.logger.Info("graphite metric bridge", v...)
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ func ProvideService(cfg *setting.Cfg, sqlStore db.DB, usageStats usagestats.Serv
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (ds *RemoteCache) getUsageStats(ctx context.Context) (map[string]interface{}, error) {
|
||||
stats := map[string]interface{}{}
|
||||
func (ds *RemoteCache) getUsageStats(ctx context.Context) (map[string]any, error) {
|
||||
stats := map[string]any{}
|
||||
stats["stats.remote_cache."+ds.Cfg.RemoteCacheOptions.Name+".count"] = 1
|
||||
encryptVal := 0
|
||||
if ds.Cfg.RemoteCacheOptions.Encryption {
|
||||
|
@ -115,7 +115,7 @@ func canNotFetchExpiredItems(t *testing.T, client CacheStorage) {
|
||||
}
|
||||
|
||||
func TestCollectUsageStats(t *testing.T) {
|
||||
wantMap := map[string]interface{}{
|
||||
wantMap := map[string]any{
|
||||
"stats.remote_cache.redis.count": 1,
|
||||
"stats.remote_cache.encrypt_enabled.count": 1,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (t *FakeSpan) IsEnded() bool {
|
||||
return t.ended
|
||||
}
|
||||
|
||||
func (t *FakeSpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue) {
|
||||
func (t *FakeSpan) SetAttributes(key string, value any, kv attribute.KeyValue) {
|
||||
if t.IsEnded() {
|
||||
panic("span already ended")
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ type Span interface {
|
||||
// SetAttributes repeats the key value pair with [string] and [any]
|
||||
// used for OpenTracing and [attribute.KeyValue] used for
|
||||
// OpenTelemetry.
|
||||
SetAttributes(key string, value interface{}, kv attribute.KeyValue)
|
||||
SetAttributes(key string, value any, kv attribute.KeyValue)
|
||||
// SetName renames the span.
|
||||
SetName(name string)
|
||||
// SetStatus can be used to indicate whether the span was
|
||||
@ -137,9 +137,9 @@ func ProvideService(cfg *setting.Cfg) (Tracer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.RegisterContextualLogProvider(func(ctx context.Context) ([]interface{}, bool) {
|
||||
log.RegisterContextualLogProvider(func(ctx context.Context) ([]any, bool) {
|
||||
if traceID := TraceIDFromContext(ctx, false); traceID != "" {
|
||||
return []interface{}{"traceID", traceID}, true
|
||||
return []any{"traceID", traceID}, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
@ -460,7 +460,7 @@ func (s OpentelemetrySpan) End() {
|
||||
s.span.End()
|
||||
}
|
||||
|
||||
func (s OpentelemetrySpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue) {
|
||||
func (s OpentelemetrySpan) SetAttributes(key string, value any, kv attribute.KeyValue) {
|
||||
s.span.SetAttributes(kv)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ func (usm *UsageStatsMock) RegisterMetricsFunc(fn MetricsFunc) {
|
||||
}
|
||||
|
||||
func (usm *UsageStatsMock) GetUsageReport(ctx context.Context) (Report, error) {
|
||||
all := make(map[string]interface{})
|
||||
all := make(map[string]any)
|
||||
for _, fn := range usm.metricsFuncs {
|
||||
fnMetrics, err := fn(ctx)
|
||||
require.NoError(usm.T, err)
|
||||
|
@ -5,17 +5,17 @@ import (
|
||||
)
|
||||
|
||||
type Report struct {
|
||||
Version string `json:"version"`
|
||||
Metrics map[string]interface{} `json:"metrics"`
|
||||
Os string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
Edition string `json:"edition"`
|
||||
HasValidLicense bool `json:"hasValidLicense"`
|
||||
Packaging string `json:"packaging"`
|
||||
UsageStatsId string `json:"usageStatsId"`
|
||||
Version string `json:"version"`
|
||||
Metrics map[string]any `json:"metrics"`
|
||||
Os string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
Edition string `json:"edition"`
|
||||
HasValidLicense bool `json:"hasValidLicense"`
|
||||
Packaging string `json:"packaging"`
|
||||
UsageStatsId string `json:"usageStatsId"`
|
||||
}
|
||||
|
||||
type MetricsFunc func(context.Context) (map[string]interface{}, error)
|
||||
type MetricsFunc func(context.Context) (map[string]any, error)
|
||||
|
||||
type SendReportCallbackFunc func()
|
||||
|
||||
|
@ -23,7 +23,7 @@ var usageStatsURL = "https://stats.grafana.org/grafana-usage-report"
|
||||
|
||||
func (uss *UsageStats) GetUsageReport(ctx context.Context) (usagestats.Report, error) {
|
||||
version := strings.ReplaceAll(uss.Cfg.BuildVersion, ".", "_")
|
||||
metrics := map[string]interface{}{}
|
||||
metrics := map[string]any{}
|
||||
start := time.Now()
|
||||
|
||||
edition := "oss"
|
||||
@ -53,7 +53,7 @@ func (uss *UsageStats) GetUsageReport(ctx context.Context) (usagestats.Report, e
|
||||
return report, nil
|
||||
}
|
||||
|
||||
func (uss *UsageStats) gatherMetrics(ctx context.Context, metrics map[string]interface{}) {
|
||||
func (uss *UsageStats) gatherMetrics(ctx context.Context, metrics map[string]any) {
|
||||
ctx, span := uss.tracer.Start(ctx, "UsageStats.GatherLoop")
|
||||
defer span.End()
|
||||
totC, errC := 0, 0
|
||||
@ -73,7 +73,7 @@ func (uss *UsageStats) gatherMetrics(ctx context.Context, metrics map[string]int
|
||||
metrics["stats.usagestats.debug.collect.error.count"] = errC
|
||||
}
|
||||
|
||||
func (uss *UsageStats) runMetricsFunc(ctx context.Context, fn usagestats.MetricsFunc) (map[string]interface{}, error) {
|
||||
func (uss *UsageStats) runMetricsFunc(ctx context.Context, fn usagestats.MetricsFunc) (map[string]any, error) {
|
||||
start := time.Now()
|
||||
ctx, span := uss.tracer.Start(ctx, "UsageStats.Gather")
|
||||
fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
|
||||
|
@ -44,8 +44,8 @@ func TestMetrics(t *testing.T) {
|
||||
sqlStore := dbtest.NewFakeDB()
|
||||
uss := createService(t, sqlStore, false)
|
||||
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{metricName: 1}, nil
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]any, error) {
|
||||
return map[string]any{metricName: 1}, nil
|
||||
})
|
||||
|
||||
_, err := uss.sendUsageStats(context.Background())
|
||||
@ -132,7 +132,7 @@ func TestMetrics(t *testing.T) {
|
||||
|
||||
require.NotNil(t, resp.responseBuffer)
|
||||
|
||||
j := make(map[string]interface{})
|
||||
j := make(map[string]any)
|
||||
err = json.Unmarshal(resp.responseBuffer.Bytes(), &j)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -143,7 +143,7 @@ func TestMetrics(t *testing.T) {
|
||||
usageId := uss.GetUsageStatsId(context.Background())
|
||||
assert.NotEmpty(t, usageId)
|
||||
|
||||
metrics, ok := j["metrics"].(map[string]interface{})
|
||||
metrics, ok := j["metrics"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
assert.EqualValues(t, 1, metrics[metricName])
|
||||
})
|
||||
@ -154,8 +154,8 @@ func TestGetUsageReport_IncludesMetrics(t *testing.T) {
|
||||
uss := createService(t, sqlStore, true)
|
||||
metricName := "stats.test_metric.count"
|
||||
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{metricName: 1}, nil
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]any, error) {
|
||||
return map[string]any{metricName: 1}, nil
|
||||
})
|
||||
|
||||
report, err := uss.GetUsageReport(context.Background())
|
||||
@ -170,16 +170,16 @@ func TestRegisterMetrics(t *testing.T) {
|
||||
|
||||
sqlStore := dbtest.NewFakeDB()
|
||||
uss := createService(t, sqlStore, false)
|
||||
metrics := map[string]interface{}{"stats.test_metric.count": 1, "stats.test_metric_second.count": 2}
|
||||
metrics := map[string]any{"stats.test_metric.count": 1, "stats.test_metric_second.count": 2}
|
||||
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{goodMetricName: 1}, nil
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]any, error) {
|
||||
return map[string]any{goodMetricName: 1}, nil
|
||||
})
|
||||
|
||||
{
|
||||
extMetrics, err := uss.externalMetrics[0](context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, map[string]interface{}{goodMetricName: 1}, extMetrics)
|
||||
assert.Equal(t, map[string]any{goodMetricName: 1}, extMetrics)
|
||||
}
|
||||
|
||||
uss.gatherMetrics(context.Background(), metrics)
|
||||
@ -189,8 +189,8 @@ func TestRegisterMetrics(t *testing.T) {
|
||||
t.Run("do not add metrics that return an error when fetched", func(t *testing.T) {
|
||||
const badMetricName = "stats.test_external_metric_error.count"
|
||||
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]interface{}, error) {
|
||||
return map[string]interface{}{badMetricName: 1}, errors.New("some error")
|
||||
uss.RegisterMetricsFunc(func(context.Context) (map[string]any, error) {
|
||||
return map[string]any{badMetricName: 1}, errors.New("some error")
|
||||
})
|
||||
uss.gatherMetrics(context.Background(), metrics)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user