Documentation ¶
Index ¶
- Variables
- func AllPluginKinds() map[string]PluginKind
- func ErrorStack(err error) *proto.Stack
- func FromGRPCError(err error) error
- func GetPluginConfig(kind PluginKind, name string, client corev1client.ConfigMapInterface) (*corev1.ConfigMap, error)
- func HandlePanic(p interface{}) error
- func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn, ...) *clientDispenser
- func NewGRPCError(err error, details ...goproto.Message) error
- func NewGRPCErrorWithCode(err error, code codes.Code, details ...goproto.Message) error
- func PluginConfigLabelSelector(kind PluginKind, name string) string
- func ValidatePluginName(name string, existingNames []string) error
- type ClientBase
- type ClientDispenser
- type HandlerInitializer
- type PluginBase
- type PluginKind
- type PluginOption
- type ProtoStackError
- type ServerMux
- type StackTracer
Constants ¶
This section is empty.
Variables ¶
var PluginKindsAdaptableTo = map[PluginKind][]PluginKind{ PluginKindBackupItemAction: {PluginKindBackupItemActionV2}, PluginKindRestoreItemAction: {PluginKindRestoreItemActionV2}, }
PluginKindsAdaptableTo if there are plugin kinds that are adaptable to newer API versions, list them here. The older (adaptable) version is the key, and the value is the full list of newer plugin kinds that are capable of adapting it.
Functions ¶
func AllPluginKinds ¶
func AllPluginKinds() map[string]PluginKind
AllPluginKinds contains all the valid plugin kinds that Velero supports, excluding PluginLister because that is not a kind that a developer would ever need to implement (it's handled by Velero and the Velero plugin library code).
func ErrorStack ¶
ErrorStack gets a stack trace, if it exists, from the provided error, and returns it as a *proto.Stack.
func FromGRPCError ¶
FromGRPCError takes a gRPC status error, extracts a stack trace from the details if it exists, and returns an error that can provide information about where it was created.
This function should be used in the internal plugin client code to convert all errors returned from the plugin server before they're passed back to the rest of the Velero codebase. This will enable them to display location information when they're logged.
func GetPluginConfig ¶ added in v1.12.0
func GetPluginConfig(kind PluginKind, name string, client corev1client.ConfigMapInterface) (*corev1.ConfigMap, error)
func HandlePanic ¶
func HandlePanic(p interface{}) error
HandlePanic is a panic handler for the server half of velero plugins.
func NewClientDispenser ¶
func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn, initFunc clientInitFunc) *clientDispenser
newClientDispenser creates a new clientDispenser.
func NewGRPCError ¶
NewGRPCError is a convenience function for creating a new gRPC error with code = codes.Unknown
func NewGRPCErrorWithCode ¶
NewGRPCErrorWithCode wraps err in a gRPC status error with the error's stack trace included in the details if it exists. This provides an easy way to send stack traces from plugin servers across the wire to the plugin client.
This function should be used in the internal plugin server code to wrap all errors before they're returned.
func PluginConfigLabelSelector ¶ added in v1.12.0
func PluginConfigLabelSelector(kind PluginKind, name string) string
func ValidatePluginName ¶
ValidatePluginName checks if the given name: - the plugin name has two parts separated by '/' - non of the above parts is empty - the prefix is a valid DNS subdomain name - a plugin with the same name does not already exist (if list of existing names is passed in)
Types ¶
type ClientBase ¶
type ClientBase struct { Plugin string Logger logrus.FieldLogger }
ClientBase implements client and contains shared fields common to all clients.
type ClientDispenser ¶
type ClientDispenser interface {
ClientFor(name string) interface{}
}
type HandlerInitializer ¶
type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error)
HandlerInitializer is a function that initializes and returns a new instance of one of Velero's plugin interfaces (ObjectStore, VolumeSnapshotter, BackupItemAction, RestoreItemAction).
type PluginBase ¶
type PluginBase struct { ClientLogger logrus.FieldLogger *ServerMux }
func NewPluginBase ¶
func NewPluginBase(options ...PluginOption) *PluginBase
type PluginKind ¶
type PluginKind string
PluginKind is a type alias for a string that describes the kind of a Velero-supported plugin.
const ( // PluginKindObjectStore represents an object store plugin. PluginKindObjectStore PluginKind = "ObjectStore" // PluginKindVolumeSnapshotter represents a volume snapshotter plugin. PluginKindVolumeSnapshotter PluginKind = "VolumeSnapshotter" // PluginKindBackupItemAction represents a backup item action plugin. PluginKindBackupItemAction PluginKind = "BackupItemAction" // PluginKindBackupItemActionV2 represents a v2 backup item action plugin. PluginKindBackupItemActionV2 PluginKind = "BackupItemActionV2" // PluginKindRestoreItemAction represents a restore item action plugin. PluginKindRestoreItemAction PluginKind = "RestoreItemAction" // PluginKindRestoreItemActionV2 represents a v2 restore item action plugin. PluginKindRestoreItemActionV2 PluginKind = "RestoreItemActionV2" // PluginKindDeleteItemAction represents a delete item action plugin. PluginKindDeleteItemAction PluginKind = "DeleteItemAction" // PluginKindPluginLister represents a plugin lister plugin. PluginKindPluginLister PluginKind = "PluginLister" )
type PluginOption ¶
type PluginOption func(base *PluginBase)
func ClientLogger ¶
func ClientLogger(logger logrus.FieldLogger) PluginOption
func ServerLogger ¶
func ServerLogger(logger logrus.FieldLogger) PluginOption
type ProtoStackError ¶
type ProtoStackError struct {
// contains filtered or unexported fields
}
func (*ProtoStackError) File ¶
func (e *ProtoStackError) File() string
func (*ProtoStackError) Function ¶
func (e *ProtoStackError) Function() string
func (*ProtoStackError) Line ¶
func (e *ProtoStackError) Line() int32
type ServerMux ¶
type ServerMux struct { Handlers map[string]interface{} ServerLog logrus.FieldLogger // contains filtered or unexported fields }
ServerMux manages multiple implementations of a single plugin kind, such as pod and pvc BackupItemActions.
func NewServerMux ¶
func NewServerMux(logger logrus.FieldLogger) *ServerMux
NewServerMux returns a new ServerMux.
func (*ServerMux) GetHandler ¶
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 (*ServerMux) Register ¶
func (m *ServerMux) Register(name string, f HandlerInitializer)
register validates the plugin name and registers the initializer for the given name.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}