plugin

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package plugin is used to manage the execution of Phobos plugins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreProtocolsSupported

func AreProtocolsSupported(protocols []string) error

AreProtocolsSupported checks if the given protocols are supported.

Types

type Installer

type Installer interface {
	EnsureLatestVersion(ctx context.Context, source string, opts ...InstallerOption) (string, error)
	InstallPlugin(ctx context.Context, source, version string, opts ...InstallerOption) error
}

Installer is the interface for installing plugins

func NewInstaller

func NewInstaller(logger hclog.Logger, defaultRegistryURL string) (Installer, error)

NewInstaller returns a new plugin installer.

type InstallerOption

type InstallerOption func(*installerOptions)

InstallerOption is a function that configures the installer.

func WithConstraints

func WithConstraints(constraints *string) InstallerOption

WithConstraints sets the version constraints for the installer. Only applicable for EnsureLatestVersion.

func WithToken

func WithToken(token *string) InstallerOption

WithToken sets the token for the installer.

type LaunchOption

type LaunchOption func(*launchOptions)

LaunchOption is a function that modifies the launch options

func WithBinaryPath

func WithBinaryPath(path string) LaunchOption

WithBinaryPath indicates the path for a local plugin binary which will be used to launch the plugin instead.

func WithDir

func WithDir(dir string) LaunchOption

WithDir will become the working directory of the plugin's command.

func WithVersion

func WithVersion(version string) LaunchOption

WithVersion sets the plugin version. Required when using a plugin from a remote registry.

type Manager

type Manager interface {
	Close()
	GetPlugins() []*PipelinePlugin
	GetPlugin(name string) (*PipelinePlugin, error)
	GetVersionForBuiltInPlugins(ctx context.Context) (string, error)
	LaunchPlugin(ctx context.Context, source string, options ...LaunchOption) error
}

Manager manages plugin execution and lifecycle

func New

func New(logger hclog.Logger) Manager

New creates a new plugin manager

type MockManager

type MockManager struct {
	mock.Mock
}

MockManager is an autogenerated mock type for the Manager type

func NewMockManager

func NewMockManager(t mockConstructorTestingTNewMockManager) *MockManager

NewMockManager creates a new instance of MockManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockManager) Close

func (_m *MockManager) Close()

Close provides a mock function with given fields:

func (*MockManager) GetPlugin

func (_m *MockManager) GetPlugin(name string) (*PipelinePlugin, error)

GetPlugin provides a mock function with given fields: name

func (*MockManager) GetPlugins

func (_m *MockManager) GetPlugins() []*PipelinePlugin

GetPlugins provides a mock function with given fields:

func (*MockManager) GetVersionForBuiltInPlugins added in v0.3.0

func (_m *MockManager) GetVersionForBuiltInPlugins(ctx context.Context) (string, error)

GetVersionForBuiltInPlugins provides a mock function with given fields: ctx

func (*MockManager) LaunchPlugin

func (_m *MockManager) LaunchPlugin(ctx context.Context, source string, options ...LaunchOption) error

LaunchPlugin provides a mock function with given fields: ctx, source, options

type PipelinePlugin

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

PipelinePlugin wraps a provider plugin instance and encapsulates functionality for interfacing with a provider

func NewPipelinePlugin

func NewPipelinePlugin(instance component.PipelinePlugin, log hclog.Logger, close func()) *PipelinePlugin

NewPipelinePlugin creates a new instance of a PipelinePlugin

func (*PipelinePlugin) Close

func (p *PipelinePlugin) Close()

Close releases plugin resources

func (*PipelinePlugin) Configure

func (p *PipelinePlugin) Configure(ctx context.Context, body hcl.Body, evalCtx *hcl.EvalContext) hcl.Diagnostics

Configure configures a provider instance with an hcl config

func (*PipelinePlugin) ExecuteAction

func (p *PipelinePlugin) ExecuteAction(ctx context.Context, actionName string, body hcl.Body, evalCtx *hcl.EvalContext, ui terminal.UI) (map[string]cty.Value, error)

ExecuteAction executes a provider action and returns the outputs

func (*PipelinePlugin) GetImpliedActionOutputs

func (p *PipelinePlugin) GetImpliedActionOutputs(ctx context.Context, actionName string) (map[string]cty.Value, error)

GetImpliedActionOutputs returns the implied outputs for an action without executing it. This is used primarily for validation

func (*PipelinePlugin) GracefulShutdown

func (p *PipelinePlugin) GracefulShutdown(ctx context.Context) error

GracefulShutdown gracefully stops the provider actions

func (*PipelinePlugin) ValidateActionInput

func (p *PipelinePlugin) ValidateActionInput(ctx context.Context, actionName string, body hcl.Body, evalCtx *hcl.EvalContext) hcl.Diagnostics

ValidateActionInput validates the hcl config against the action input struct

func (*PipelinePlugin) ValidateConfig

func (p *PipelinePlugin) ValidateConfig(ctx context.Context, body hcl.Body, evalCtx *hcl.EvalContext) hcl.Diagnostics

ValidateConfig validates a provider hcl config

type RegistryPluginDownloadResponse

type RegistryPluginDownloadResponse struct {
	OperatingSystem string   `json:"os"`
	Arch            string   `json:"arch"`
	Filename        string   `json:"filename"`
	DownloadURL     string   `json:"download_url"`
	SHASumsURL      string   `json:"shasums_url"`
	SHASum          string   `json:"shasum"`
	Protocols       []string `json:"protocols"`
}

RegistryPluginDownloadResponse is the response for downloading a plugin.

type RegistryPluginPlatform

type RegistryPluginPlatform struct {
	OperatingSystem string `json:"os"`
	Arch            string `json:"arch"`
}

RegistryPluginPlatform represents a platform for a plugin version

type RegistryPluginVersion

type RegistryPluginVersion struct {
	Version   string                   `json:"version"`
	Protocols []string                 `json:"protocols"`
	Platforms []RegistryPluginPlatform `json:"platforms"`
}

RegistryPluginVersion represents a plugin version

type RegistryPluginVersionList

type RegistryPluginVersionList struct {
	Versions []RegistryPluginVersion `json:"versions"`
}

RegistryPluginVersionList contains a list of plugin versions

type Source

type Source struct {
	Hostname     svchost.Hostname
	Organization string
	Name         string
}

Source defines the plugin Source with three parts (hostname, organization, name). The hostname is optional and defaults to the default registry URL.

func ParseSource

func ParseSource(s string, defaultRegistryURL *string) (*Source, error)

ParseSource parses the plugin source and returns the provider.

func (*Source) String

func (s *Source) String() string

String returns the string representation of the source.

Jump to

Keyboard shortcuts

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