pluggable

package
v1.0.0-alpha.15 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

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 InternalPluginHandler

type InternalPluginHandler func(key string, config interface{}) (protocol plugins.Plugin, err error)

type PluginLoader

type PluginLoader struct {
	*config.Config

	SelectedPluginKey    *plugins.PluginKey
	SelectedPluginConfig interface{}
	// contains filtered or unexported fields
}

PluginLoader handles finding, configuring and loading porter plugins.

func NewPluginLoader

func NewPluginLoader(c *config.Config, createInternalPlugin InternalPluginHandler) *PluginLoader

func (*PluginLoader) Load

func (l *PluginLoader) Load(pluginType PluginTypeConfig) (interface{}, func(), 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