chore: enable use-any from revive

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-01-17 07:58:10 +01:00
parent 5b1738abf8
commit cbba3bdde7
139 changed files with 798 additions and 799 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ type BackupItemActionPlugin struct {
}
// GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newBackupItemActionGRPCClient), nil
}
@@ -46,7 +46,7 @@ type BackupItemActionGRPCClient struct {
grpcClient protobiav1.BackupItemActionClient
}
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &BackupItemActionGRPCClient{
ClientBase: base,
grpcClient: protobiav1.NewBackupItemActionClient(clientConn),
@@ -156,7 +156,7 @@ func TestBackupItemActionGRPCServerExecute(t *testing.T) {
s := &BackupItemActionGRPCServer{mux: &common.ServerMux{
ServerLog: velerotest.NewLogger(),
Handlers: map[string]interface{}{
Handlers: map[string]any{
"xyz": itemAction,
},
}}
@@ -34,7 +34,7 @@ type BackupItemActionPlugin struct {
}
// GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newBackupItemActionGRPCClient), nil
}
@@ -46,7 +46,7 @@ type BackupItemActionGRPCClient struct {
grpcClient protobiav2.BackupItemActionClient
}
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &BackupItemActionGRPCClient{
ClientBase: base,
grpcClient: protobiav2.NewBackupItemActionClient(clientConn),
@@ -159,7 +159,7 @@ func TestBackupItemActionGRPCServerExecute(t *testing.T) {
s := &BackupItemActionGRPCServer{mux: &common.ServerMux{
ServerLog: velerotest.NewLogger(),
Handlers: map[string]interface{}{
Handlers: map[string]any{
"xyz": itemAction,
},
}}
@@ -28,7 +28,7 @@ type ClientBase struct {
}
type ClientDispenser interface {
ClientFor(name string) interface{}
ClientFor(name string) any
}
// clientDispenser supports the initialization and retrieval of multiple implementations for a single plugin kind, such as
@@ -41,10 +41,10 @@ type clientDispenser struct {
// initFunc returns a client that implements a plugin interface, such as ObjectStore.
initFunc clientInitFunc
// clients keeps track of all the initialized implementations.
clients map[string]interface{}
clients map[string]any
}
type clientInitFunc func(base *ClientBase, clientConn *grpc.ClientConn) interface{}
type clientInitFunc func(base *ClientBase, clientConn *grpc.ClientConn) any
// newClientDispenser creates a new clientDispenser.
func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn, initFunc clientInitFunc) *clientDispenser {
@@ -52,13 +52,13 @@ func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn,
clientConn: clientConn,
logger: logger,
initFunc: initFunc,
clients: make(map[string]interface{}),
clients: make(map[string]any),
}
}
// ClientFor returns a gRPC client stub for the implementation of a plugin named name. If the client stub does not
// currently exist, clientFor creates it.
func (cd *clientDispenser) ClientFor(name string) interface{} {
func (cd *clientDispenser) ClientFor(name string) any {
if client, found := cd.clients[name]; found {
return client
}
@@ -36,7 +36,7 @@ func TestNewClientDispenser(t *testing.T) {
clientConn := new(grpc.ClientConn)
c := 3
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) interface{} {
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) any {
return c
}
@@ -52,7 +52,7 @@ func TestClientFor(t *testing.T) {
c := new(fakeClient)
count := 0
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) interface{} {
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) any {
c.base = base
c.clientConn = clientConn
count++
+1 -1
View File
@@ -24,7 +24,7 @@ import (
)
// HandlePanic is a panic handler for the server half of velero plugins.
func HandlePanic(p interface{}) error {
func HandlePanic(p any) error {
if p == nil {
return nil
}
+4 -4
View File
@@ -27,13 +27,13 @@ import (
// HandlerInitializer is a function that initializes and returns a new instance of one of Velero's plugin interfaces
// (ObjectStore, VolumeSnapshotter, BackupItemAction, RestoreItemAction).
type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error)
type HandlerInitializer func(logger logrus.FieldLogger) (any, error)
// ServerMux manages multiple implementations of a single plugin kind, such as pod and pvc BackupItemActions.
type ServerMux struct {
kind PluginKind
initializers map[string]HandlerInitializer
Handlers map[string]interface{}
Handlers map[string]any
ServerLog logrus.FieldLogger
}
@@ -41,7 +41,7 @@ type ServerMux struct {
func NewServerMux(logger logrus.FieldLogger) *ServerMux {
return &ServerMux{
initializers: make(map[string]HandlerInitializer),
Handlers: make(map[string]interface{}),
Handlers: make(map[string]any),
ServerLog: logger,
}
}
@@ -63,7 +63,7 @@ func (m *ServerMux) Names() []string {
// GetHandler returns the instance for a plugin with the given name. If an instance has already been initialized,
// that is returned. Otherwise, the instance is initialized by calling its initialization function.
func (m *ServerMux) GetHandler(name string) (interface{}, error) {
func (m *ServerMux) GetHandler(name string) (any, error) {
if instance, found := m.Handlers[name]; found {
return instance, nil
}
+1 -1
View File
@@ -34,7 +34,7 @@ type DeleteItemActionPlugin struct {
}
// GRPCClient returns a DeleteItemAction gRPC client.
func (p *DeleteItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *DeleteItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newDeleteItemActionGRPCClient), nil
}
@@ -44,7 +44,7 @@ type DeleteItemActionGRPCClient struct {
grpcClient proto.DeleteItemActionClient
}
func newDeleteItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newDeleteItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &DeleteItemActionGRPCClient{
ClientBase: base,
grpcClient: proto.NewDeleteItemActionClient(clientConn),
+2 -2
View File
@@ -30,7 +30,7 @@ func ExampleNewServer_volumeSnapshotter() {
Serve() // serve the plugin
}
func newVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
func newVolumeSnapshotter(logger logrus.FieldLogger) (any, error) {
return &VolumeSnapshotter{FieldLogger: logger}, nil
}
@@ -97,7 +97,7 @@ func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
// Implement all methods for the DeleteItemAction interface
func newDeleteItemAction(logger logrus.FieldLogger) (interface{}, error) {
func newDeleteItemAction(logger logrus.FieldLogger) (any, error) {
return DeleteItemAction{FieldLogger: logger}, nil
}
@@ -34,7 +34,7 @@ type ItemBlockActionPlugin struct {
}
// GRPCClient returns a clientDispenser for ItemBlockAction gRPC clients.
func (p *ItemBlockActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *ItemBlockActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newItemBlockActionGRPCClient), nil
}
@@ -45,7 +45,7 @@ type ItemBlockActionGRPCClient struct {
grpcClient protoibav1.ItemBlockActionClient
}
func newItemBlockActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newItemBlockActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &ItemBlockActionGRPCClient{
ClientBase: base,
grpcClient: protoibav1.NewItemBlockActionClient(clientConn),
@@ -132,7 +132,7 @@ func TestItemBlockActionGRPCServerGetRelatedItems(t *testing.T) {
s := &ItemBlockActionGRPCServer{mux: &common.ServerMux{
ServerLog: velerotest.NewLogger(),
Handlers: map[string]interface{}{
Handlers: map[string]any{
"xyz": itemAction,
},
}}
+1 -1
View File
@@ -34,7 +34,7 @@ type ObjectStorePlugin struct {
}
// GRPCClient returns an ObjectStore gRPC client.
func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newObjectStoreGRPCClient), nil
}
+1 -1
View File
@@ -44,7 +44,7 @@ type ObjectStoreGRPCClient struct {
grpcClient proto.ObjectStoreClient
}
func newObjectStoreGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newObjectStoreGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &ObjectStoreGRPCClient{
ClientBase: base,
grpcClient: proto.NewObjectStoreClient(clientConn),
+1 -1
View File
@@ -69,7 +69,7 @@ func NewPluginListerPlugin(impl PluginLister) *PluginListerPlugin {
//////////////////////////////////////////////////////////////////////////////
// GRPCClient returns a PluginLister gRPC client.
func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return &PluginListerGRPCClient{grpcClient: proto.NewPluginListerClient(clientConn)}, nil
}
+1 -1
View File
@@ -24,7 +24,7 @@ import (
)
func TestPluginImplementationsAreGRPCPlugins(t *testing.T) {
pluginImpls := []interface{}{
pluginImpls := []any{
new(VolumeSnapshotterPlugin),
new(BackupItemActionPlugin),
new(ObjectStorePlugin),
+1 -1
View File
@@ -34,7 +34,7 @@ type RestoreItemActionPlugin struct {
}
// GRPCClient returns a RestoreItemAction gRPC client.
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newRestoreItemActionGRPCClient), nil
}
@@ -47,7 +47,7 @@ type RestoreItemActionGRPCClient struct {
grpcClient proto.RestoreItemActionClient
}
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &RestoreItemActionGRPCClient{
ClientBase: base,
grpcClient: proto.NewRestoreItemActionClient(clientConn),
@@ -34,7 +34,7 @@ type RestoreItemActionPlugin struct {
}
// GRPCClient returns a RestoreItemAction gRPC client.
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newRestoreItemActionGRPCClient), nil
}
@@ -48,7 +48,7 @@ type RestoreItemActionGRPCClient struct {
grpcClient protoriav2.RestoreItemActionClient
}
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &RestoreItemActionGRPCClient{
ClientBase: base,
grpcClient: protoriav2.NewRestoreItemActionClient(clientConn),
+1 -1
View File
@@ -34,7 +34,7 @@ type VolumeSnapshotterPlugin struct {
}
// GRPCClient returns a VolumeSnapshotter gRPC client.
func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
return common.NewClientDispenser(p.ClientLogger, clientConn, newVolumeSnapshotterGRPCClient), nil
}
@@ -43,7 +43,7 @@ type VolumeSnapshotterGRPCClient struct {
grpcClient proto.VolumeSnapshotterClient
}
func newVolumeSnapshotterGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
func newVolumeSnapshotterGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
return &VolumeSnapshotterGRPCClient{
ClientBase: base,
grpcClient: proto.NewVolumeSnapshotterClient(clientConn),