Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -27,17 +27,17 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data := make(map[string]any)
|
||||
if err := json.Unmarshal(b, &data); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
info, ok := data["info"].(map[string]interface{})
|
||||
info, ok := data["info"].(map[string]any)
|
||||
if info == nil {
|
||||
log.Fatal("expecting 'info' field")
|
||||
}
|
||||
if !ok {
|
||||
log.Fatal("unable to turn info field into map[string]interface{}")
|
||||
log.Fatal("unable to turn info field into map[string]any")
|
||||
}
|
||||
|
||||
if info["title"] == nil {
|
||||
@@ -49,9 +49,9 @@ func main() {
|
||||
log.Fatal("no definitions")
|
||||
}
|
||||
|
||||
defs := definitions.(map[string]interface{})
|
||||
defs := definitions.(map[string]any)
|
||||
for k, v := range defs {
|
||||
vMap := v.(map[string]interface{})
|
||||
vMap := v.(map[string]any)
|
||||
refKey, ok := vMap[RefKey]
|
||||
if !ok {
|
||||
continue
|
||||
@@ -63,24 +63,24 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
paths, ok := data["paths"].(map[string]interface{})
|
||||
paths, ok := data["paths"].(map[string]any)
|
||||
if !ok {
|
||||
log.Fatal("no paths")
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
path, ok := path.(map[string]interface{})
|
||||
path, ok := path.(map[string]any)
|
||||
if !ok {
|
||||
log.Fatal("invalid path")
|
||||
}
|
||||
|
||||
for _, op := range path {
|
||||
op, ok := op.(map[string]interface{})
|
||||
op, ok := op.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
tags, ok := op["tags"].([]interface{})
|
||||
tags, ok := op["tags"].([]any)
|
||||
if !ok {
|
||||
log.Println("invalid op, skipping")
|
||||
continue
|
||||
|
||||
@@ -797,7 +797,7 @@ alertmanager_config: |
|
||||
return
|
||||
}
|
||||
require.Nil(t, err)
|
||||
// Override the map[string]interface{} field for test simplicity.
|
||||
// Override the map[string]any field for test simplicity.
|
||||
// It's tested in Test_GettableUserConfigRoundtrip.
|
||||
out.amSimple = nil
|
||||
require.Equal(t, tc.output, out)
|
||||
|
||||
@@ -431,7 +431,7 @@ func (d Duration) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -444,12 +444,12 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (d Duration) MarshalYAML() (interface{}, error) {
|
||||
func (d Duration) MarshalYAML() (any, error) {
|
||||
return time.Duration(d).Seconds(), nil
|
||||
}
|
||||
|
||||
func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var v interface{}
|
||||
func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var v any
|
||||
if err := unmarshal(&v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ type AlertRuleExport struct {
|
||||
|
||||
// AlertQueryExport is the provisioned export of models.AlertQuery.
|
||||
type AlertQueryExport struct {
|
||||
RefID string `json:"refId" yaml:"refId"`
|
||||
QueryType string `json:"queryType,omitempty" yaml:"queryType,omitempty"`
|
||||
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange,omitempty" yaml:"relativeTimeRange,omitempty"`
|
||||
DatasourceUID string `json:"datasourceUid" yaml:"datasourceUid"`
|
||||
Model map[string]interface{} `json:"model" yaml:"model"`
|
||||
RefID string `json:"refId" yaml:"refId"`
|
||||
QueryType string `json:"queryType,omitempty" yaml:"queryType,omitempty"`
|
||||
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange,omitempty" yaml:"relativeTimeRange,omitempty"`
|
||||
DatasourceUID string `json:"datasourceUid" yaml:"datasourceUid"`
|
||||
Model map[string]any `json:"model" yaml:"model"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user