framework

package
v1.12.2-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 33 Imported by: 56

Documentation

Overview

Package framework is the common package that any plugin client will need to import, for example, both plugin authors and Velero core.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handshake

func Handshake() plugin.HandshakeConfig

Handshake returns the configuration information that allows go-plugin clients and servers to perform a handshake.

func ValidateObjectStoreConfigKeys added in v1.2.0

func ValidateObjectStoreConfigKeys(config map[string]string, validKeys ...string) error

ValidateObjectStoreConfigKeys ensures that an object store's config is valid by making sure each `config` key is in the `validKeys` list. The special keys "bucket" and "prefix" are always considered valid.

func ValidateVolumeSnapshotterConfigKeys added in v1.2.0

func ValidateVolumeSnapshotterConfigKeys(config map[string]string, validKeys ...string) error

ValidateVolumeSnapshotterConfigKeys ensures that a volume snapshotter's config is valid by making sure each `config` key is in the `validKeys` list.

Types

type ActionResolver added in v1.8.0

type ActionResolver interface {
	ResolveAction(helper discovery.Helper, action velero.Applicable, log logrus.FieldLogger) (ResolvedAction, error)
}

type BackupItemActionGRPCClient

type BackupItemActionGRPCClient struct {
	*common.ClientBase
	// contains filtered or unexported fields
}

BackupItemActionGRPCClient implements the backup/ItemAction interface and uses a gRPC client to make calls to the plugin server.

func (*BackupItemActionGRPCClient) AppliesTo

func (*BackupItemActionGRPCClient) Execute

type BackupItemActionGRPCServer

type BackupItemActionGRPCServer struct {
	// contains filtered or unexported fields
}

BackupItemActionGRPCServer implements the proto-generated BackupItemAction interface, and accepts gRPC calls and forwards them to an implementation of the pluggable interface.

func (*BackupItemActionGRPCServer) AppliesTo

func (*BackupItemActionGRPCServer) Execute

func (s *BackupItemActionGRPCServer) Execute(
	ctx context.Context, req *proto.ExecuteRequest) (response *proto.ExecuteResponse, err error)

type BackupItemActionPlugin

type BackupItemActionPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	*common.PluginBase
}

BackupItemActionPlugin is an implementation of go-plugin's Plugin interface with support for gRPC for the backup/ItemAction interface.

func NewBackupItemActionPlugin

func NewBackupItemActionPlugin(options ...common.PluginOption) *BackupItemActionPlugin

NewBackupItemActionPlugin constructs a BackupItemActionPlugin.

func (*BackupItemActionPlugin) GRPCClient

func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.

func (*BackupItemActionPlugin) GRPCServer

func (p *BackupItemActionPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers a BackupItemAction gRPC server.

type BackupItemActionResolver added in v1.8.0

type BackupItemActionResolver struct {
	// contains filtered or unexported fields
}

func NewBackupItemActionResolver added in v1.8.0

func NewBackupItemActionResolver(actions []biav1.BackupItemAction) BackupItemActionResolver

func (BackupItemActionResolver) ResolveActions added in v1.8.0

type BackupItemActionResolverV2 added in v1.11.0

type BackupItemActionResolverV2 struct {
	// contains filtered or unexported fields
}

func NewBackupItemActionResolverV2 added in v1.11.0

func NewBackupItemActionResolverV2(actions []biav2.BackupItemAction) BackupItemActionResolverV2

func (BackupItemActionResolverV2) ResolveActions added in v1.11.0

type BackupItemResolvedAction added in v1.8.0

type BackupItemResolvedAction struct {
	biav1.BackupItemAction
	// contains filtered or unexported fields
}

func (BackupItemResolvedAction) ShouldUse added in v1.8.0

func (recv BackupItemResolvedAction) ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
	log logrus.FieldLogger) bool

type BackupItemResolvedActionV2 added in v1.11.0

type BackupItemResolvedActionV2 struct {
	biav2.BackupItemAction
	// contains filtered or unexported fields
}

func (BackupItemResolvedActionV2) ShouldUse added in v1.11.0

func (recv BackupItemResolvedActionV2) ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
	log logrus.FieldLogger) bool

type CloseFunc

type CloseFunc func() error

CloseFunc is used to signal to the source of data that the StreamReadCloser has been closed.

type DeleteItemActionGRPCClient added in v1.5.0

type DeleteItemActionGRPCClient struct {
	*common.ClientBase
	// contains filtered or unexported fields
}

DeleteItemActionGRPCClient implements the DeleteItemAction interface and uses a gRPC client to make calls to the plugin server.

func (*DeleteItemActionGRPCClient) AppliesTo added in v1.5.0

func (*DeleteItemActionGRPCClient) Execute added in v1.5.0

type DeleteItemActionGRPCServer added in v1.5.0

type DeleteItemActionGRPCServer struct {
	// contains filtered or unexported fields
}

DeleteItemActionGRPCServer implements the proto-generated DeleteItemActionServer interface, and accepts gRPC calls and forwards them to an implementation of the pluggable interface.

func (*DeleteItemActionGRPCServer) AppliesTo added in v1.5.0

func (*DeleteItemActionGRPCServer) Execute added in v1.5.0

type DeleteItemActionPlugin added in v1.5.0

type DeleteItemActionPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	*common.PluginBase
}

DeleteItemActionPlugin is an implementation of go-plugin's Plugin interface with support for gRPC for the restore/ItemAction interface.

func NewDeleteItemActionPlugin added in v1.5.0

func NewDeleteItemActionPlugin(options ...common.PluginOption) *DeleteItemActionPlugin

NewDeleteItemActionPlugin constructs a DeleteItemActionPlugin.

func (*DeleteItemActionPlugin) GRPCClient added in v1.5.0

func (p *DeleteItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns a DeleteItemAction gRPC client.

func (*DeleteItemActionPlugin) GRPCServer added in v1.5.0

func (p *DeleteItemActionPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers a DeleteItemAction gRPC server.

type DeleteItemActionResolver added in v1.8.0

type DeleteItemActionResolver struct {
	// contains filtered or unexported fields
}

func NewDeleteItemActionResolver added in v1.8.0

func NewDeleteItemActionResolver(actions []velero.DeleteItemAction) DeleteItemActionResolver

func (DeleteItemActionResolver) ResolveActions added in v1.8.0

type DeleteItemResolvedAction added in v1.8.0

type DeleteItemResolvedAction struct {
	velero.DeleteItemAction
	// contains filtered or unexported fields
}

func (DeleteItemResolvedAction) ShouldUse added in v1.8.0

func (recv DeleteItemResolvedAction) ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
	log logrus.FieldLogger) bool

type Interface

type Interface interface {
	plugin.Plugin

	// names returns a list of all the registered implementations for this plugin (such as "pod" and "pvc" for
	// BackupItemAction).
	Names() []string
}

Interface represents a Velero plugin.

type ObjectStoreGRPCClient

type ObjectStoreGRPCClient struct {
	*common.ClientBase
	// contains filtered or unexported fields
}

ObjectStoreGRPCClient implements the ObjectStore interface and uses a gRPC client to make calls to the plugin server.

func (*ObjectStoreGRPCClient) CreateSignedURL

func (c *ObjectStoreGRPCClient) CreateSignedURL(bucket, key string, ttl time.Duration) (string, error)

CreateSignedURL creates a pre-signed URL for the given bucket and key that expires after ttl.

func (*ObjectStoreGRPCClient) DeleteObject

func (c *ObjectStoreGRPCClient) DeleteObject(bucket, key string) error

DeleteObject removes object with the specified key from the given bucket.

func (*ObjectStoreGRPCClient) GetObject

func (c *ObjectStoreGRPCClient) GetObject(bucket, key string) (io.ReadCloser, error)

GetObject retrieves the object with the given key from the specified bucket in object storage.

func (*ObjectStoreGRPCClient) Init

func (c *ObjectStoreGRPCClient) Init(config map[string]string) error

Init prepares the ObjectStore for usage using the provided map of configuration key-value pairs. It returns an error if the ObjectStore cannot be initialized from the provided config.

func (*ObjectStoreGRPCClient) ListCommonPrefixes

func (c *ObjectStoreGRPCClient) ListCommonPrefixes(bucket, prefix, delimiter string) ([]string, error)

ListCommonPrefixes gets a list of all object key prefixes that come after the provided prefix and before the provided delimiter (this is often used to simulate a directory hierarchy in object storage).

func (*ObjectStoreGRPCClient) ListObjects

func (c *ObjectStoreGRPCClient) ListObjects(bucket, prefix string) ([]string, error)

ListObjects gets a list of all objects in bucket that have the same prefix.

func (*ObjectStoreGRPCClient) ObjectExists

func (c *ObjectStoreGRPCClient) ObjectExists(bucket, key string) (bool, error)

ObjectExists checks if there is an object with the given key in the object storage bucket.

func (*ObjectStoreGRPCClient) PutObject

func (c *ObjectStoreGRPCClient) PutObject(bucket, key string, body io.Reader) error

PutObject creates a new object using the data in body within the specified object storage bucket with the given key.

type ObjectStoreGRPCServer

type ObjectStoreGRPCServer struct {
	// contains filtered or unexported fields
}

ObjectStoreGRPCServer implements the proto-generated ObjectStoreServer interface, and accepts gRPC calls and forwards them to an implementation of the pluggable interface.

func (*ObjectStoreGRPCServer) CreateSignedURL

CreateSignedURL creates a pre-signed URL for the given bucket and key that expires after ttl.

func (*ObjectStoreGRPCServer) DeleteObject

func (s *ObjectStoreGRPCServer) DeleteObject(ctx context.Context, req *proto.DeleteObjectRequest) (response *proto.Empty, err error)

DeleteObject removes object with the specified key from the given bucket.

func (*ObjectStoreGRPCServer) GetObject

GetObject retrieves the object with the given key from the specified bucket in object storage.

func (*ObjectStoreGRPCServer) Init

func (s *ObjectStoreGRPCServer) Init(ctx context.Context, req *proto.ObjectStoreInitRequest) (response *proto.Empty, err error)

Init prepares the ObjectStore for usage using the provided map of configuration key-value pairs. It returns an error if the ObjectStore cannot be initialized from the provided config.

func (*ObjectStoreGRPCServer) ListCommonPrefixes

ListCommonPrefixes gets a list of all object key prefixes that start with the specified prefix and stop at the next instance of the provided delimiter (this is often used to simulate a directory hierarchy in object storage).

func (*ObjectStoreGRPCServer) ListObjects

func (s *ObjectStoreGRPCServer) ListObjects(ctx context.Context, req *proto.ListObjectsRequest) (response *proto.ListObjectsResponse, err error)

ListObjects gets a list of all objects in bucket that have the same prefix.

func (*ObjectStoreGRPCServer) ObjectExists

func (s *ObjectStoreGRPCServer) ObjectExists(ctx context.Context, req *proto.ObjectExistsRequest) (response *proto.ObjectExistsResponse, err error)

ObjectExists checks if there is an object with the given key in the object storage bucket.

func (*ObjectStoreGRPCServer) PutObject

func (s *ObjectStoreGRPCServer) PutObject(stream proto.ObjectStore_PutObjectServer) (err error)

PutObject creates a new object using the data in body within the specified object storage bucket with the given key.

type ObjectStorePlugin

type ObjectStorePlugin struct {
	plugin.NetRPCUnsupportedPlugin
	*common.PluginBase
}

ObjectStorePlugin is an implementation of go-plugin's Plugin interface with support for gRPC for the cloudprovider/ObjectStore interface.

func NewObjectStorePlugin

func NewObjectStorePlugin(options ...common.PluginOption) *ObjectStorePlugin

NewObjectStorePlugin construct an ObjectStorePlugin.

func (*ObjectStorePlugin) GRPCClient

func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns an ObjectStore gRPC client.

func (*ObjectStorePlugin) GRPCServer

func (p *ObjectStorePlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers an ObjectStore gRPC server.

type PluginIdentifier

type PluginIdentifier struct {
	Command string
	Kind    common.PluginKind
	Name    string
}

PluginIdentifier uniquely identifies a plugin by command, kind, and name.

type PluginLister

type PluginLister interface {
	ListPlugins() ([]PluginIdentifier, error)
}

PluginLister lists plugins.

func NewPluginLister

func NewPluginLister(plugins ...PluginIdentifier) PluginLister

NewPluginLister returns a new PluginLister for plugins.

type PluginListerGRPCClient

type PluginListerGRPCClient struct {
	// contains filtered or unexported fields
}

PluginListerGRPCClient implements PluginLister and uses a gRPC client to make calls to the plugin server.

func (*PluginListerGRPCClient) ListPlugins

func (c *PluginListerGRPCClient) ListPlugins() ([]PluginIdentifier, error)

ListPlugins uses the gRPC client to request the list of plugins from the server. It translates the protobuf response to []PluginIdentifier.

type PluginListerGRPCServer

type PluginListerGRPCServer struct {
	// contains filtered or unexported fields
}

PluginListerGRPCServer implements the proto-generated PluginLister gRPC service interface. It accepts gRPC calls, forwards them to impl, and translates the responses to protobuf.

func (*PluginListerGRPCServer) ListPlugins

ListPlugins returns a list of registered plugins, delegating to s.impl to perform the listing.

type PluginListerPlugin

type PluginListerPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	// contains filtered or unexported fields
}

PluginListerPlugin is a go-plugin Plugin for a PluginLister.

func NewPluginListerPlugin

func NewPluginListerPlugin(impl PluginLister) *PluginListerPlugin

NewPluginListerPlugin creates a new PluginListerPlugin with impl as the server-side implementation.

func (*PluginListerPlugin) GRPCClient

func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns a PluginLister gRPC client.

func (*PluginListerPlugin) GRPCServer

func (p *PluginListerPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers a PluginLister gRPC server.

type ReceiveFunc

type ReceiveFunc func() ([]byte, error)

ReceiveFunc is a function that either returns a slice of an arbitrary number of bytes OR an error. Returning an io.EOF means there is no more data to be read; any other error is considered an actual error.

type ResolvedAction added in v1.8.0

type ResolvedAction interface {
	// ShouldUse returns true if the resolved namespaces, resource names and labels match those passed in the parameters.
	// metadata is optional and may be nil
	ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
		log logrus.FieldLogger) bool
}

ResolvedAction is an action that has had the namespaces, resources names and labels to include or exclude resolved

type RestoreItemActionGRPCClient

type RestoreItemActionGRPCClient struct {
	*common.ClientBase
	// contains filtered or unexported fields
}

RestoreItemActionGRPCClient implements the backup/ItemAction interface and uses a gRPC client to make calls to the plugin server.

func (*RestoreItemActionGRPCClient) AppliesTo

func (*RestoreItemActionGRPCClient) Execute

type RestoreItemActionGRPCServer

type RestoreItemActionGRPCServer struct {
	// contains filtered or unexported fields
}

RestoreItemActionGRPCServer implements the proto-generated RestoreItemActionServer interface, and accepts gRPC calls and forwards them to an implementation of the pluggable interface.

func (*RestoreItemActionGRPCServer) AppliesTo

func (*RestoreItemActionGRPCServer) Execute

type RestoreItemActionPlugin

type RestoreItemActionPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	*common.PluginBase
}

RestoreItemActionPlugin is an implementation of go-plugin's Plugin interface with support for gRPC for the restore/ItemAction interface.

func NewRestoreItemActionPlugin

func NewRestoreItemActionPlugin(options ...common.PluginOption) *RestoreItemActionPlugin

NewRestoreItemActionPlugin constructs a RestoreItemActionPlugin.

func (*RestoreItemActionPlugin) GRPCClient

func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns a RestoreItemAction gRPC client.

func (*RestoreItemActionPlugin) GRPCServer

func (p *RestoreItemActionPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers a RestoreItemAction gRPC server.

type RestoreItemActionResolver added in v1.8.0

type RestoreItemActionResolver struct {
	// contains filtered or unexported fields
}

func NewRestoreItemActionResolver added in v1.8.0

func NewRestoreItemActionResolver(actions []riav1.RestoreItemAction) RestoreItemActionResolver

func (RestoreItemActionResolver) ResolveActions added in v1.8.0

type RestoreItemActionResolverV2 added in v1.11.0

type RestoreItemActionResolverV2 struct {
	// contains filtered or unexported fields
}

func NewRestoreItemActionResolverV2 added in v1.11.0

func NewRestoreItemActionResolverV2(actions []riav2.RestoreItemAction) RestoreItemActionResolverV2

func (RestoreItemActionResolverV2) ResolveActions added in v1.11.0

type RestoreItemResolvedAction added in v1.8.0

type RestoreItemResolvedAction struct {
	riav1.RestoreItemAction
	// contains filtered or unexported fields
}

func (RestoreItemResolvedAction) ShouldUse added in v1.8.0

func (recv RestoreItemResolvedAction) ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
	log logrus.FieldLogger) bool

type RestoreItemResolvedActionV2 added in v1.11.0

type RestoreItemResolvedActionV2 struct {
	riav2.RestoreItemAction
	// contains filtered or unexported fields
}

func (RestoreItemResolvedActionV2) ShouldUse added in v1.11.0

func (recv RestoreItemResolvedActionV2) ShouldUse(groupResource schema.GroupResource, namespace string, metadata metav1.Object,
	log logrus.FieldLogger) bool

type Server

type Server interface {
	// BindFlags defines the plugin server's command-line flags
	// on the provided FlagSet. If you're not sure what flag set
	// to use, pflag.CommandLine is the default set of command-line
	// flags.
	//
	// This method must be called prior to calling .Serve().
	BindFlags(flags *pflag.FlagSet) Server

	// RegisterBackupItemAction registers a backup item action. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterBackupItemAction(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterBackupItemActions registers multiple backup item actions.
	RegisterBackupItemActions(map[string]common.HandlerInitializer) Server

	// RegisterBackupItemActionV2 registers a v2 backup item action. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterBackupItemActionV2(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterBackupItemActionsV2 registers multiple v2 backup item actions.
	RegisterBackupItemActionsV2(map[string]common.HandlerInitializer) Server

	// RegisterVolumeSnapshotter registers a volume snapshotter. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterVolumeSnapshotter(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterVolumeSnapshotters registers multiple volume snapshotters.
	RegisterVolumeSnapshotters(map[string]common.HandlerInitializer) Server

	// RegisterObjectStore registers an object store. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterObjectStore(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterObjectStores registers multiple object stores.
	RegisterObjectStores(map[string]common.HandlerInitializer) Server

	// RegisterRestoreItemAction registers a restore item action. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterRestoreItemAction(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterRestoreItemActions registers multiple restore item actions.
	RegisterRestoreItemActions(map[string]common.HandlerInitializer) Server

	// RegisterRestoreItemActionV2 registers a v2 restore item action. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterRestoreItemActionV2(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterRestoreItemActionsV2 registers multiple v2 restore item actions.
	RegisterRestoreItemActionsV2(map[string]common.HandlerInitializer) Server

	// RegisterDeleteItemAction registers a delete item action. Accepted format
	// for the plugin name is <DNS subdomain>/<non-empty name>.
	RegisterDeleteItemAction(pluginName string, initializer common.HandlerInitializer) Server

	// RegisterDeleteItemActions registers multiple Delete item actions.
	RegisterDeleteItemActions(map[string]common.HandlerInitializer) Server

	// Server runs the plugin server.
	Serve()
}

Server serves registered plugin implementations.

func NewServer

func NewServer() Server

NewServer returns a new Server

Example (VolumeSnapshotter)
package main

import (
	"github.com/sirupsen/logrus"
	"k8s.io/apimachinery/pkg/runtime"

	"github.com/vmware-tanzu/velero/pkg/plugin/velero"
)

func main() {
	NewServer(). // call the server
			RegisterVolumeSnapshotter("example.io/volumesnapshotter", newVolumeSnapshotter). // register the plugin with a valid name
			RegisterDeleteItemAction("example.io/delete-item-action", newDeleteItemAction).
			Serve() // serve the plugin
}

func newVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
	return &VolumeSnapshotter{FieldLogger: logger}, nil
}

type VolumeSnapshotter struct {
	FieldLogger logrus.FieldLogger
}

// Implement all methods for the VolumeSnapshotter interface...
func (b *VolumeSnapshotter) Init(config map[string]string) error {
	b.FieldLogger.Infof("VolumeSnapshotter.Init called")

	// ...

	return nil
}

func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) {
	b.FieldLogger.Infof("CreateVolumeFromSnapshot called")

	// ...

	return "volumeID", nil
}

func (b *VolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
	b.FieldLogger.Infof("GetVolumeID called")

	// ...

	return "volumeID", nil
}

func (b *VolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
	b.FieldLogger.Infof("SetVolumeID called")

	// ...

	return nil, nil
}

func (b *VolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
	b.FieldLogger.Infof("GetVolumeInfo called")

	// ...

	return "volumeFilesystemType", nil, nil
}

func (b *VolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error) {
	b.FieldLogger.Infof("CreateSnapshot called")

	// ...

	return "snapshotID", nil
}

func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
	b.FieldLogger.Infof("DeleteSnapshot called")

	// ...

	return nil
}

// Implement all methods for the DeleteItemAction interface

func newDeleteItemAction(logger logrus.FieldLogger) (interface{}, error) {
	return DeleteItemAction{FieldLogger: logger}, nil
}

type DeleteItemAction struct {
	FieldLogger logrus.FieldLogger
}

func (d *DeleteItemAction) AppliesTo() (velero.ResourceSelector, error) {
	d.FieldLogger.Infof("AppliesTo called")

	// ...

	return velero.ResourceSelector{}, nil
}

func (d *DeleteItemAction) Execute(input *velero.DeleteItemActionExecuteInput) error {
	d.FieldLogger.Infof("Execute called")

	// ...

	return nil
}
Output:

type StreamReadCloser

type StreamReadCloser struct {
	// contains filtered or unexported fields
}

StreamReadCloser wraps a ReceiveFunc and a CloseSendFunc to implement io.ReadCloser.

func (*StreamReadCloser) Close

func (s *StreamReadCloser) Close() error

func (*StreamReadCloser) Read

func (s *StreamReadCloser) Read(p []byte) (n int, err error)

type VolumeSnapshotterGRPCClient

type VolumeSnapshotterGRPCClient struct {
	*common.ClientBase
	// contains filtered or unexported fields
}

VolumeSnapshotterGRPCClient implements the cloudprovider.VolumeSnapshotter interface and uses a gRPC client to make calls to the plugin server.

func (*VolumeSnapshotterGRPCClient) CreateSnapshot

func (c *VolumeSnapshotterGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error)

CreateSnapshot creates a snapshot of the specified block volume, and applies the provided set of tags to the snapshot.

func (*VolumeSnapshotterGRPCClient) CreateVolumeFromSnapshot

func (c *VolumeSnapshotterGRPCClient) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error)

CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot, and with the specified type and IOPS (if using provisioned IOPS).

func (*VolumeSnapshotterGRPCClient) DeleteSnapshot

func (c *VolumeSnapshotterGRPCClient) DeleteSnapshot(snapshotID string) error

DeleteSnapshot deletes the specified volume snapshot.

func (*VolumeSnapshotterGRPCClient) GetVolumeID

func (*VolumeSnapshotterGRPCClient) GetVolumeInfo

func (c *VolumeSnapshotterGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)

GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block volume.

func (*VolumeSnapshotterGRPCClient) Init

func (c *VolumeSnapshotterGRPCClient) Init(config map[string]string) error

Init prepares the VolumeSnapshotter for usage using the provided map of configuration key-value pairs. It returns an error if the VolumeSnapshotter cannot be initialized from the provided config.

func (*VolumeSnapshotterGRPCClient) SetVolumeID

type VolumeSnapshotterGRPCServer

type VolumeSnapshotterGRPCServer struct {
	// contains filtered or unexported fields
}

VolumeSnapshotterGRPCServer implements the proto-generated VolumeSnapshotterServer interface, and accepts gRPC calls and forwards them to an implementation of the pluggable interface.

func (*VolumeSnapshotterGRPCServer) CreateSnapshot

CreateSnapshot creates a snapshot of the specified block volume, and applies the provided set of tags to the snapshot.

func (*VolumeSnapshotterGRPCServer) CreateVolumeFromSnapshot

func (s *VolumeSnapshotterGRPCServer) CreateVolumeFromSnapshot(ctx context.Context, req *proto.CreateVolumeRequest) (response *proto.CreateVolumeResponse, err error)

CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot, and with the specified type and IOPS (if using provisioned IOPS).

func (*VolumeSnapshotterGRPCServer) DeleteSnapshot

func (s *VolumeSnapshotterGRPCServer) DeleteSnapshot(ctx context.Context, req *proto.DeleteSnapshotRequest) (response *proto.Empty, err error)

DeleteSnapshot deletes the specified volume snapshot.

func (*VolumeSnapshotterGRPCServer) GetVolumeID

func (*VolumeSnapshotterGRPCServer) GetVolumeInfo

GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block volume.

func (*VolumeSnapshotterGRPCServer) Init

Init prepares the VolumeSnapshotter for usage using the provided map of configuration key-value pairs. It returns an error if the VolumeSnapshotter cannot be initialized from the provided config.

func (*VolumeSnapshotterGRPCServer) SetVolumeID

type VolumeSnapshotterPlugin

type VolumeSnapshotterPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	*common.PluginBase
}

VolumeSnapshotterPlugin is an implementation of go-plugin's Plugin interface with support for gRPC for the cloudprovider/VolumeSnapshotter interface.

func NewVolumeSnapshotterPlugin

func NewVolumeSnapshotterPlugin(options ...common.PluginOption) *VolumeSnapshotterPlugin

NewVolumeSnapshotterPlugin constructs a VolumeSnapshotterPlugin.

func (*VolumeSnapshotterPlugin) GRPCClient

func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient returns a VolumeSnapshotter gRPC client.

func (*VolumeSnapshotterPlugin) GRPCServer

func (p *VolumeSnapshotterPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

GRPCServer registers a VolumeSnapshotter gRPC server.

Directories

Path Synopsis
backupitemaction
v2
restoreitemaction
v2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL