pluggable

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Overview

Package pluggable manages configuring and connecting to Porter's plugins.

Index

Constants

View Source
const (
	// PluginStartTimeoutDefault is the default amount of time to wait for a plugin
	// to start. Override with PluginStartTimeoutEnvVar.
	PluginStartTimeoutDefault = 5 * time.Second

	// PluginStopTimeoutDefault is the default amount of time to wait for a plugin
	// to stop (kill). Override with PluginStopTimeoutEnvVar.
	PluginStopTimeoutDefault = 5 * time.Second

	// PluginStartTimeoutEnvVar is the environment variable used to override
	// PluginStartTimeoutDefault.
	PluginStartTimeoutEnvVar = "PORTER_PLUGIN_START_TIMEOUT"

	// PluginStopTimeoutEnvVar is the environment variable used to override
	// PluginStopTimeoutDefault.
	PluginStopTimeoutEnvVar = "PORTER_PLUGIN_STOP_TIMEOUT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	GetName() string
	GetPluginSubKey() string
	GetConfig() interface{}
}

Entry defines a configuration entry for an item that can be managed by a plugin.

type PluginConnection added in v1.0.1

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

PluginConnection represents a connection to a plugin. It wraps the hashicorp/go-plugin library.

func NewPluginConnection added in v1.0.1

func NewPluginConnection(c *config.Config, pluginType PluginTypeConfig, pluginKey plugins.PluginKey) *PluginConnection

func (*PluginConnection) Close added in v1.0.1

func (c *PluginConnection) Close(ctx context.Context) error

Close releases the resources held by the plugin connection. Blocks until the plugin process closes. Pass a context to control the graceful shutdown of the plugin.

func (*PluginConnection) GetClient added in v1.0.1

func (c *PluginConnection) GetClient() interface{}

GetClient returns the raw connection to the pluginProtocol. This value should be cast to the plugin protocol interface, such as plugins.StorageProtocol or plugins.SecretsProtocol.

func (*PluginConnection) IsPluginRunning added in v1.0.1

func (c *PluginConnection) IsPluginRunning() bool

IsPluginRunning indicates is the plugin process is still running. Used for testing only.

func (*PluginConnection) Start added in v1.0.1

func (c *PluginConnection) Start(ctx context.Context, pluginCfg io.Reader) error

Start establishes a connection to the plugin. * pluginCfg is the resolved plugin configuration section from the Porter config file

func (*PluginConnection) String added in v1.0.1

func (c *PluginConnection) String() string

String returns the plugin key name

type PluginLoader

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

PluginLoader handles finding, configuring and loading porter plugins.

func NewPluginLoader

func NewPluginLoader(c *config.Config) *PluginLoader

func (*PluginLoader) Load

func (l *PluginLoader) Load(ctx context.Context, pluginType PluginTypeConfig) (*PluginConnection, error)

Load a plugin, returning the plugin's interface which the caller must then cast to the typed interface, a cleanup function to stop the plugin when finished communicating with it, and an error if the plugin could not be loaded.

type PluginTypeConfig

type PluginTypeConfig struct {
	// Name of the plugin type interface.
	Interface string

	// Plugin to communicate with the plugin
	Plugin plugin.Plugin

	// GetDefaultPluggable is the function on porter's configuration
	// to retrieve a pluggable configuration value's named default instance to use, e.g. "default-storage"
	GetDefaultPluggable func(c *config.Config) string

	// GetPluggable is the function on porter's configuration
	// to retrieve a named pluggable instance, e.g. a storage named "azure"
	GetPluggable func(c *config.Config, name string) (Entry, error)

	// GetDefaultPlugin is the function on porter's configuration
	// to retrieve the default plugin to use for a type of plugin, e.g. "storage-plugin"
	GetDefaultPlugin func(c *config.Config) string

	// ProtocolVersion is the version of the protocol used by this plugin.
	ProtocolVersion uint
}

PluginTypeConfig defines a set of functions to access a type of plugin's data in the porter config file.

Jump to

Keyboard shortcuts

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