plugin

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package plugin provides functionality for dynamically loading provider plugins.

Package plugin provides functionality for dynamically loading provider plugins.

Package plugin provides functionality for dynamically loading provider plugins.

Package plugin provides functionality for dynamically loading provider plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultPluginValidator

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

DefaultPluginValidator is the default implementation of PluginValidator

func NewDefaultPluginValidator

func NewDefaultPluginValidator() *DefaultPluginValidator

NewDefaultPluginValidator creates a new default plugin validator

func (*DefaultPluginValidator) ValidateCompatibility

func (v *DefaultPluginValidator) ValidateCompatibility(metadata *PluginMetadata) error

ValidateCompatibility validates compatibility with the framework

func (*DefaultPluginValidator) ValidatePlugin

func (v *DefaultPluginValidator) ValidatePlugin(plugin *ProviderPlugin) error

ValidatePlugin validates a plugin

type LegacyPluginAdapter

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

LegacyPluginAdapter adapts legacy plugins to the new plugin interface

func (*LegacyPluginAdapter) CreateProvider

func (a *LegacyPluginAdapter) CreateProvider(config *core.ProviderConfig) (core.Provider, error)

CreateProvider creates a new provider instance

func (*LegacyPluginAdapter) GetMetadata

func (a *LegacyPluginAdapter) GetMetadata() *PluginMetadata

GetMetadata returns metadata about the plugin

func (*LegacyPluginAdapter) ValidateConfig

func (a *LegacyPluginAdapter) ValidateConfig(config *core.ProviderConfig) error

ValidateConfig validates the provider configuration

type PluginDiscovery

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

PluginDiscovery is responsible for discovering provider plugins

func NewPluginDiscovery

func NewPluginDiscovery(pluginDirs []string) *PluginDiscovery

NewPluginDiscovery creates a new plugin discovery

func (*PluginDiscovery) AddPluginDir

func (d *PluginDiscovery) AddPluginDir(dir string)

AddPluginDir adds a plugin directory

func (*PluginDiscovery) AddValidator

func (d *PluginDiscovery) AddValidator(validator PluginValidator)

AddValidator adds a plugin validator

func (*PluginDiscovery) DiscoverPlugins

func (d *PluginDiscovery) DiscoverPlugins() ([]*ProviderPlugin, []error)

DiscoverPlugins discovers plugins in the plugin directories

func (*PluginDiscovery) GetPluginDirs

func (d *PluginDiscovery) GetPluginDirs() []string

GetPluginDirs returns the plugin directories

type PluginInterface

type PluginInterface interface {
	// GetMetadata returns metadata about the plugin
	GetMetadata() *PluginMetadata

	// CreateProvider creates a new provider instance
	CreateProvider(config *core.ProviderConfig) (core.Provider, error)

	// ValidateConfig validates the provider configuration
	ValidateConfig(config *core.ProviderConfig) error
}

PluginInterface defines the interface that all provider plugins must implement

type PluginManager

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

PluginManager is responsible for managing provider plugins

func NewPluginManager

func NewPluginManager(providerFactory *factory.ProviderFactory, pluginDirs []string) *PluginManager

NewPluginManager creates a new plugin manager

func (*PluginManager) AddPluginDir

func (m *PluginManager) AddPluginDir(dir string)

AddPluginDir adds a plugin directory

func (*PluginManager) GetAllPlugins

func (m *PluginManager) GetAllPlugins() []*ProviderPlugin

GetAllPlugins returns all plugins

func (*PluginManager) GetPlugin

func (m *PluginManager) GetPlugin(name string) (*ProviderPlugin, error)

GetPlugin returns a plugin by name

func (*PluginManager) GetPluginByProviderType

func (m *PluginManager) GetPluginByProviderType(providerType core.ProviderType) (*ProviderPlugin, error)

GetPluginByProviderType returns a plugin by provider type

func (*PluginManager) GetPluginDirs

func (m *PluginManager) GetPluginDirs() []string

GetPluginDirs returns the plugin directories

func (*PluginManager) LoadPlugin

func (m *PluginManager) LoadPlugin(pluginPath string) (*ProviderPlugin, error)

LoadPlugin loads a plugin from a file

func (*PluginManager) LoadPluginsFromDirs

func (m *PluginManager) LoadPluginsFromDirs() ([]string, []error)

LoadPluginsFromDirs loads plugins from directories

func (*PluginManager) UnloadPlugin

func (m *PluginManager) UnloadPlugin(name string) error

UnloadPlugin unloads a plugin

func (*PluginManager) ValidatePlugin

func (m *PluginManager) ValidatePlugin(plugin *ProviderPlugin) error

ValidatePlugin validates a plugin

func (*PluginManager) ValidatePluginConfig

func (m *PluginManager) ValidatePluginConfig(plugin *ProviderPlugin, config *core.ProviderConfig) error

ValidatePluginConfig validates a plugin configuration

type PluginMetadata

type PluginMetadata struct {
	// Name is the name of the plugin
	Name string `json:"name"`
	// Version is the version of the plugin
	Version string `json:"version"`
	// Author is the author of the plugin
	Author string `json:"author"`
	// Description is a description of the plugin
	Description string `json:"description"`
	// ProviderType is the type of provider
	ProviderType core.ProviderType `json:"provider_type"`
	// SupportedModels is a list of models supported by the plugin
	SupportedModels []string `json:"supported_models,omitempty"`
	// MinFrameworkVersion is the minimum framework version required by the plugin
	MinFrameworkVersion string `json:"min_framework_version"`
	// MaxFrameworkVersion is the maximum framework version supported by the plugin
	MaxFrameworkVersion string `json:"max_framework_version,omitempty"`
	// Tags is a list of tags for the plugin
	Tags []string `json:"tags,omitempty"`
}

PluginMetadata represents metadata about a provider plugin

type PluginValidator

type PluginValidator interface {
	// ValidatePlugin validates a plugin
	ValidatePlugin(plugin *ProviderPlugin) error

	// ValidateCompatibility validates compatibility with the framework
	ValidateCompatibility(metadata *PluginMetadata) error
}

PluginValidator defines the interface for validating plugins

type ProviderPlugin

type ProviderPlugin struct {
	// Name is the name of the plugin
	Name string
	// Path is the path to the plugin
	Path string
	// ProviderType is the type of provider
	ProviderType core.ProviderType
	// Constructor is the provider constructor (legacy)
	Constructor factory.ProviderConstructor
	// Plugin is the plugin instance
	Plugin *plugin.Plugin
	// Metadata is the plugin metadata
	Metadata *PluginMetadata
	// PluginInterface is the plugin interface
	PluginInterface PluginInterface
	// IsLegacy indicates if this is a legacy plugin
	IsLegacy bool
}

ProviderPlugin represents a provider plugin

Jump to

Keyboard shortcuts

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