Documentation
¶
Overview ¶
Package plugins provides a plugin system for custom pre-commit hooks
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrManifestNil = errors.New("manifest cannot be nil") ErrPluginNameEmpty = errors.New("plugin name is required") ErrExecutableEmpty = errors.New("plugin executable is required") )
Define plugin errors
var ( ErrPluginAlreadyRegistered = errors.New("plugin already registered") ErrPluginNil = errors.New("plugin cannot be nil") ErrNoManifestFound = errors.New("no manifest file found (looked for plugin.yaml, plugin.yml, plugin.json)") ErrPluginsLoadFailed = errors.New("failed to load some plugins") )
Define registry errors
Functions ¶
func ValidateManifest ¶
func ValidateManifest(manifest *PluginManifest) []string
ValidateManifest validates a plugin manifest without loading it
Types ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin represents a custom check implemented as an external executable
func NewPlugin ¶
func NewPlugin(manifest *PluginManifest, directory string) (*Plugin, error)
NewPlugin creates a new plugin from a manifest and directory
func (*Plugin) Description ¶
Description returns a brief description of the plugin
func (*Plugin) FilterFiles ¶
FilterFiles filters the list of files to only those this plugin should process
type PluginManifest ¶
type PluginManifest struct {
// Basic metadata
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Description string `json:"description" yaml:"description"`
Author string `json:"author,omitempty" yaml:"author,omitempty"`
License string `json:"license,omitempty" yaml:"license,omitempty"`
Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty"`
// Execution configuration
Executable string `json:"executable" yaml:"executable"`
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
FilePatterns []string `json:"file_patterns" yaml:"file_patterns"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Category string `json:"category,omitempty" yaml:"category,omitempty"`
RequiresFiles bool `json:"requires_files,omitempty" yaml:"requires_files,omitempty"`
Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
// Advanced configuration
Dependencies []string `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
MinVersion string `json:"min_go_pre_commit_version,omitempty" yaml:"min_go_pre_commit_version,omitempty"`
MaxVersion string `json:"max_go_pre_commit_version,omitempty" yaml:"max_go_pre_commit_version,omitempty"`
// Security settings
ReadOnly bool `json:"read_only,omitempty" yaml:"read_only,omitempty"`
AllowedPaths []string `json:"allowed_paths,omitempty" yaml:"allowed_paths,omitempty"`
MaxMemoryMB int `json:"max_memory_mb,omitempty" yaml:"max_memory_mb,omitempty"`
MaxCPUPercent int `json:"max_cpu_percent,omitempty" yaml:"max_cpu_percent,omitempty"`
}
PluginManifest defines the structure of a plugin configuration file
type PluginMetadata ¶
type PluginMetadata struct {
Name string
Description string
FilePatterns []string
EstimatedDuration time.Duration
Dependencies []string
DefaultTimeout time.Duration
Category string
RequiresFiles bool
Version string
Author string
}
PluginMetadata contains metadata about a plugin
type PluginRequest ¶
type PluginRequest struct {
Command string `json:"command"`
Files []string `json:"files"`
Config map[string]string `json:"config,omitempty"`
}
PluginRequest is the JSON structure sent to plugins via stdin
type PluginResponse ¶
type PluginResponse struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
Modified []string `json:"modified,omitempty"`
Output string `json:"output,omitempty"`
}
PluginResponse is the JSON structure expected from plugins via stdout
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages plugin discovery and loading
func NewRegistry ¶
NewRegistry creates a new plugin registry
func (*Registry) LoadPlugins ¶
LoadPlugins discovers and loads all plugins from the registry directory
func (*Registry) RemovePlugin ¶
RemovePlugin removes a plugin from the registry