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