mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 22:23:15 +00:00
chore: enable use-any from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -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++
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user