plugin

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "ARK_PLUGIN",
	MagicCookieValue: "hello",
}

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

Functions

func NewLogger

func NewLogger() logrus.FieldLogger

NewLogger returns a logger that is suitable for use within an Ark plugin.

func Serve

func Serve(p Interface)

Serve serves the plugin p.

Types

type BackupItemActionGRPCClient

type BackupItemActionGRPCClient struct {
	// 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

func (*BackupItemActionGRPCClient) SetLog

type BackupItemActionGRPCServer

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

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

func (*BackupItemActionGRPCServer) AppliesTo

func (*BackupItemActionGRPCServer) Execute

type BackupItemActionPlugin

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

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

func NewBackupItemActionPlugin

func NewBackupItemActionPlugin(itemAction arkbackup.ItemAction) *BackupItemActionPlugin

NewBackupItemActionPlugin constructs a BackupItemActionPlugin.

func (*BackupItemActionPlugin) GRPCClient

func (p *BackupItemActionPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error)

GRPCClient returns a BackupItemAction gRPC client.

func (*BackupItemActionPlugin) GRPCServer

func (p *BackupItemActionPlugin) GRPCServer(s *grpc.Server) error

GRPCServer registers a BackupItemAction gRPC server.

func (*BackupItemActionPlugin) Kind

type BlockStoreGRPCClient

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

BlockStoreGRPCClient implements the cloudprovider.BlockStore interface and uses a gRPC client to make calls to the plugin server.

func (*BlockStoreGRPCClient) CreateSnapshot

func (c *BlockStoreGRPCClient) 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 (*BlockStoreGRPCClient) CreateVolumeFromSnapshot

func (c *BlockStoreGRPCClient) 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 (*BlockStoreGRPCClient) DeleteSnapshot

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

DeleteSnapshot deletes the specified volume snapshot.

func (*BlockStoreGRPCClient) GetVolumeID

func (c *BlockStoreGRPCClient) GetVolumeID(pv runtime.Unstructured) (string, error)

func (*BlockStoreGRPCClient) GetVolumeInfo

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

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

func (*BlockStoreGRPCClient) Init

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

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

func (*BlockStoreGRPCClient) IsVolumeReady

func (c *BlockStoreGRPCClient) IsVolumeReady(volumeID, volumeAZ string) (bool, error)

IsVolumeReady returns whether the specified volume is ready to be used.

func (*BlockStoreGRPCClient) SetVolumeID

func (c *BlockStoreGRPCClient) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)

type BlockStoreGRPCServer

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

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

func (*BlockStoreGRPCServer) CreateSnapshot

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

func (*BlockStoreGRPCServer) CreateVolumeFromSnapshot

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

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

func (*BlockStoreGRPCServer) DeleteSnapshot

DeleteSnapshot deletes the specified volume snapshot.

func (*BlockStoreGRPCServer) GetVolumeID

func (*BlockStoreGRPCServer) GetVolumeInfo

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

func (*BlockStoreGRPCServer) Init

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

func (*BlockStoreGRPCServer) IsVolumeReady

IsVolumeReady returns whether the specified volume is ready to be used.

func (*BlockStoreGRPCServer) SetVolumeID

type BlockStorePlugin

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

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

func NewBlockStorePlugin

func NewBlockStorePlugin(blockStore cloudprovider.BlockStore) *BlockStorePlugin

NewBlockStorePlugin constructs a BlockStorePlugin.

func (*BlockStorePlugin) GRPCClient

func (p *BlockStorePlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error)

GRPCClient returns a BlockStore gRPC client.

func (*BlockStorePlugin) GRPCServer

func (p *BlockStorePlugin) GRPCServer(s *grpc.Server) error

GRPCServer registers a BlockStore gRPC server.

func (*BlockStorePlugin) Kind

func (p *BlockStorePlugin) Kind() PluginKind

type CloseFunc

type CloseFunc func() error

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

type Interface

type Interface interface {
	plugin.Plugin

	// Kind returns the PluginKind for the plugin.
	Kind() PluginKind
}

Interface represents an Ark plugin.

type Manager

type Manager interface {
	// GetObjectStore returns the plugin implementation of the
	// cloudprovider.ObjectStore interface with the specified name.
	GetObjectStore(name string) (cloudprovider.ObjectStore, error)

	// GetBlockStore returns the plugin implementation of the
	// cloudprovider.BlockStore interface with the specified name.
	GetBlockStore(name string) (cloudprovider.BlockStore, error)

	// GetBackupItemActions returns all backup.ItemAction plugins.
	// These plugin instances should ONLY be used for a single backup
	// (mainly because each one outputs to a per-backup log),
	// and should be terminated upon completion of the backup with
	// CloseBackupItemActions().
	GetBackupItemActions(backupName string) ([]backup.ItemAction, error)

	// CloseBackupItemActions terminates the plugin sub-processes that
	// are hosting BackupItemAction plugins for the given backup name.
	CloseBackupItemActions(backupName string) error

	// GetRestoreItemActions returns all restore.ItemAction plugins.
	// These plugin instances should ONLY be used for a single restore
	// (mainly because each one outputs to a per-restore log),
	// and should be terminated upon completion of the restore with
	// CloseRestoreItemActions().
	GetRestoreItemActions(restoreName string) ([]restore.ItemAction, error)

	// CloseRestoreItemActions terminates the plugin sub-processes that
	// are hosting RestoreItemAction plugins for the given restore name.
	CloseRestoreItemActions(restoreName string) error

	// CleanupClients kills all plugin subprocesses.
	CleanupClients()
}

Manager exposes functions for getting implementations of the pluggable Ark interfaces.

func NewManager

func NewManager(logger logrus.FieldLogger, level logrus.Level, pluginDir string) (Manager, error)

NewManager constructs a manager for getting plugin implementations.

type ObjectStoreGRPCClient

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

ObjectStoreGRPCClient implements the cloudprovider.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, delimiter string) ([]string, error)

ListCommonPrefixes gets a list of all object key prefixes that come 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) 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

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

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 come before the provided delimiter (this is often used to simulate a directory hierarchy in object storage).

func (*ObjectStoreGRPCServer) ListObjects

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

func (*ObjectStoreGRPCServer) PutObject

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
	// contains filtered or unexported fields
}

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

func NewObjectStorePlugin

func NewObjectStorePlugin(objectStore cloudprovider.ObjectStore) *ObjectStorePlugin

NewObjectStorePlugin construct an ObjectStorePlugin.

func (*ObjectStorePlugin) GRPCClient

func (p *ObjectStorePlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error)

GRPCClient returns an ObjectStore gRPC client.

func (*ObjectStorePlugin) GRPCServer

func (p *ObjectStorePlugin) GRPCServer(s *grpc.Server) error

GRPCServer registers an ObjectStore gRPC server.

func (*ObjectStorePlugin) Kind

func (p *ObjectStorePlugin) Kind() PluginKind

type PluginKind

type PluginKind string

PluginKind is a type alias for a string that describes the kind of an Ark-supported plugin.

const (
	// PluginKindObjectStore is the Kind string for
	// an Object Store plugin.
	PluginKindObjectStore PluginKind = "objectstore"

	// PluginKindBlockStore is the Kind string for
	// a Block Store plugin.
	PluginKindBlockStore PluginKind = "blockstore"

	// PluginKindCloudProvider is the Kind string for
	// a CloudProvider plugin (i.e. an Object & Block
	// store).
	//
	// NOTE that it is highly likely that in subsequent
	// versions of Ark this kind of plugin will be replaced
	// with a different mechanism for providing multiple
	// plugin impls within a single binary. This should
	// probably not be used.
	PluginKindCloudProvider PluginKind = "cloudprovider"

	// PluginKindBackupItemAction is the Kind string for
	// a Backup ItemAction plugin.
	PluginKindBackupItemAction PluginKind = "backupitemaction"

	// PluginKindRestoreItemAction is the Kind string for
	// a Restore ItemAction plugin.
	PluginKindRestoreItemAction PluginKind = "restoreitemaction"
)

func (PluginKind) String

func (k PluginKind) String() string

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 RestoreItemActionGRPCClient

type RestoreItemActionGRPCClient struct {
	// 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

func (*RestoreItemActionGRPCClient) SetLog

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
	// contains filtered or unexported fields
}

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

func NewRestoreItemActionPlugin

func NewRestoreItemActionPlugin(itemAction restore.ItemAction) *RestoreItemActionPlugin

NewRestoreItemActionPlugin constructs a RestoreItemActionPlugin.

func (*RestoreItemActionPlugin) GRPCClient

func (p *RestoreItemActionPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error)

GRPCClient returns a RestoreItemAction gRPC client.

func (*RestoreItemActionPlugin) GRPCServer

func (p *RestoreItemActionPlugin) GRPCServer(s *grpc.Server) error

GRPCServer registers a RestoreItemAction gRPC server.

func (*RestoreItemActionPlugin) Kind

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)

Directories

Path Synopsis
Package generated is a generated protocol buffer package.
Package generated is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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