diff --git a/client/config/peerhost.go b/client/config/peerhost.go index 6b69aa49d..356058369 100644 --- a/client/config/peerhost.go +++ b/client/config/peerhost.go @@ -324,7 +324,7 @@ type DownloadOption struct { CacheRecursiveMetadata time.Duration `mapstructure:"cacheRecursiveMetadata" yaml:"cacheRecursiveMetadata"` } -type ResourceClientsOption map[string]interface{} +type ResourceClientsOption map[string]any type TransportOption struct { DialTimeout time.Duration `mapstructure:"dialTimeout" yaml:"dialTimeout"` diff --git a/cmd/dfget/cmd/root.go b/cmd/dfget/cmd/root.go index 416f41a0b..e411f3ee9 100644 --- a/cmd/dfget/cmd/root.go +++ b/cmd/dfget/cmd/root.go @@ -249,7 +249,7 @@ func loadSourceClients(cmd *cobra.Command) error { if !os.IsNotExist(err) { logger.Warnf("load daemon config err: %s, use default config", err) } - if err = source.InitSourceClients(map[string]interface{}{}); err != nil { + if err = source.InitSourceClients(map[string]any{}); err != nil { logger.Errorf("init source clients with default config err: %s", err) return err } diff --git a/pkg/rpc/interceptor.go b/pkg/rpc/interceptor.go index 4b6531bad..5948b4f1d 100644 --- a/pkg/rpc/interceptor.go +++ b/pkg/rpc/interceptor.go @@ -67,9 +67,9 @@ type Refresher interface { Refresh() error } -// UnaryClientInterceptor returns a new unary client interceptor that refresh dynconfig addresses when calling error. +// RefresherUnaryClientInterceptor returns a new unary client interceptor that refresh dynconfig addresses when calling error. func RefresherUnaryClientInterceptor(r Refresher) grpc.UnaryClientInterceptor { - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { err := invoker(ctx, method, req, reply, cc, opts...) if s, ok := status.FromError(err); ok { if s.Code() == codes.ResourceExhausted || s.Code() == codes.Unavailable { @@ -82,7 +82,7 @@ func RefresherUnaryClientInterceptor(r Refresher) grpc.UnaryClientInterceptor { } } -// StreamClientInterceptor returns a new stream client interceptor that refresh dynconfig addresses when calling error. +// RefresherStreamClientInterceptor returns a new stream client interceptor that refresh dynconfig addresses when calling error. func RefresherStreamClientInterceptor(r Refresher) grpc.StreamClientInterceptor { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { clientStream, err := streamer(ctx, desc, cc, method, opts...) diff --git a/pkg/source/clients/orasprotocol/oras_source_client.go b/pkg/source/clients/orasprotocol/oras_source_client.go index 0f326cdaf..89b424d7d 100644 --- a/pkg/source/clients/orasprotocol/oras_source_client.go +++ b/pkg/source/clients/orasprotocol/oras_source_client.go @@ -210,14 +210,14 @@ func fetchAuthInfo(host string, skipCheckExist bool) (string, error) { return "", err } - var jsonData map[string]interface{} + var jsonData map[string]any if err = json.Unmarshal(databytes, &jsonData); err != nil { return "", err } for _, v := range jsonData { - for registry, v1 := range (v).(map[string]interface{}) { - for _, credentials := range (v1).(map[string]interface{}) { + for registry, v1 := range (v).(map[string]any) { + for _, credentials := range (v1).(map[string]any) { if registry == host { auth = credentials.(string) } @@ -268,7 +268,7 @@ func (client *orasSourceClient) fetchTokenWithHeader(ctx context.Context, authHe } defer response.Body.Close() - var tokenData map[string]interface{} + var tokenData map[string]any if err = json.Unmarshal(token, &tokenData); err != nil { return "", err } diff --git a/pkg/source/source_client_builder.go b/pkg/source/source_client_builder.go index 0a86c60b0..4507e02c1 100644 --- a/pkg/source/source_client_builder.go +++ b/pkg/source/source_client_builder.go @@ -27,7 +27,7 @@ import ( var ( resourceClientBuilder = map[string]ResourceClientBuilder{} - resourceClientOptions = map[string]interface{}{} + resourceClientOptions = map[string]any{} resourceDirector = map[string]Director{} ) @@ -78,7 +78,7 @@ func UnRegisterBuilder(scheme string) { } // InitSourceClients will initialize all resource clients which registered by RegisterBuilder. -func InitSourceClients(opts map[string]interface{}) error { +func InitSourceClients(opts map[string]any) error { // save options for resource plugin resourceClientOptions = opts diff --git a/scheduler/networktopology/network_topology_test.go b/scheduler/networktopology/network_topology_test.go index 8a9e32352..8d2ae9320 100644 --- a/scheduler/networktopology/network_topology_test.go +++ b/scheduler/networktopology/network_topology_test.go @@ -309,7 +309,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{"6", "5", "4", "3", "2", "1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{"6", "5", "4", "3", "2", "1"}) }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) { assert := assert.New(t) @@ -342,7 +342,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{"1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{"1"}) }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) { assert := assert.New(t) @@ -426,7 +426,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{"foo", "5", "4", "3", "2", "1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{"foo", "5", "4", "3", "2", "1"}) }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) { assert := assert.New(t) @@ -456,7 +456,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{6, "5", "4", "3", "2", "1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{6, "5", "4", "3", "2", "1"}) }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) { assert := assert.New(t) @@ -486,7 +486,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{nil, "5", "4", "3", "2", "1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{nil, "5", "4", "3", "2", "1"}) mockRDBClient.ExpectSet(probedCountKeys[0], 0, 0).SetVal("ok") }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) { @@ -523,7 +523,7 @@ func TestNetworkTopology_FindProbedHosts(t *testing.T) { probedCountKeys = append(probedCountKeys, pkgredis.MakeProbedCountKeyInScheduler(host.ID)) } - mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]interface{}{nil, "5", "4", "3", "2", "1"}) + mockRDBClient.ExpectMGet(probedCountKeys...).SetVal([]any{nil, "5", "4", "3", "2", "1"}) mockRDBClient.ExpectSet(probedCountKeys[0], 0, 0).SetErr(errors.New("Initialize the probedCount value of host in redis error")) }, expect: func(t *testing.T, networkTopology NetworkTopology, err error, hosts []*resource.Host) {