plugin

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MPL-2.0 Imports: 47 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 LaunchPluginsInput added in v0.58.0

type LaunchPluginsInput struct {
	// PluginsToInitialize are the plugin blocks to install and launch.
	PluginsToInitialize []*config.Plugin
	// PluginRequirements is the plugin_requirements block from the HCL config.
	PluginRequirements *config.PluginRequirements
	// WorkingDir is the working directory for launched plugin processes.
	WorkingDir *string
}

LaunchPluginsInput contains the input for LaunchPlugins.

type Manager

type Manager interface {
	Close()
	GetPlugins() []*PipelinePlugin
	GetPlugin(name string) (*PipelinePlugin, error)
	LaunchPlugins(ctx context.Context, input *LaunchPluginsInput) error
}

Manager manages plugin execution and lifecycle.

func NewManager added in v0.58.0

func NewManager(logger hclog.Logger, endpoint string, registryTokenFunc RegistryTokenFunc, outputFunc OutputFunc) (Manager, error)

NewManager creates a new plugin manager.

type MockInstaller added in v0.58.0

type MockInstaller struct {
	mock.Mock
}

MockInstaller is an autogenerated mock type for the Installer type

func NewMockInstaller added in v0.58.0

func NewMockInstaller(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockInstaller

NewMockInstaller creates a new instance of MockInstaller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockInstaller) EnsureLatestVersion added in v0.58.0

func (_m *MockInstaller) EnsureLatestVersion(ctx context.Context, source string, opts ...InstallerOption) (string, error)

EnsureLatestVersion provides a mock function with given fields: ctx, source, opts

func (*MockInstaller) InstallPlugin added in v0.58.0

func (_m *MockInstaller) InstallPlugin(ctx context.Context, source string, version string, opts ...InstallerOption) error

InstallPlugin provides a mock function with given fields: ctx, source, version, opts

type MockManager

type MockManager struct {
	mock.Mock
}

MockManager is an autogenerated mock type for the Manager type

func NewMockManager

func NewMockManager(t interface {
	mock.TestingT
	Cleanup(func())
}) *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. The first argument is typically a *testing.T value.

func (*MockManager) Close

func (_m *MockManager) Close()

Close provides a mock function with no 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 no fields

func (*MockManager) LaunchPlugins added in v0.58.0

func (_m *MockManager) LaunchPlugins(ctx context.Context, input *LaunchPluginsInput) error

LaunchPlugins provides a mock function with given fields: ctx, input

type OutputFunc added in v0.58.0

type OutputFunc func(format string, args ...any)

OutputFunc is a callback for logging progress messages.

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, closeFn 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 RegistryTokenFunc added in v0.58.0

type RegistryTokenFunc func(hostname string) (*string, error)

RegistryTokenFunc returns a token for authenticating with the plugin registry. Return nil if no authentication is needed.

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