plugins

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

README

NetScout-Go Plugin System

Overview

NetScout-Go uses a modular plugin system where each plugin is contained in its own directory with configuration and implementation files. This makes it easy to add, remove, or update plugins independently.

The Plugin Built on the Go programming language can be compiled into the same binary as the server, allowing for easy deployment on to remote devices like Raspberry Pi. The plugin system is designed to be flexible and extensible, allowing developers to create custom network diagnostic tools.

Plugin Structure

Each plugin resides in its own directory under app/plugins/plugins/. For example:

app/plugins/plugins/
  ├── ping/
  │   ├── plugin.json   # Plugin metadata and parameters
  │   └── plugin.go     # Plugin implementation
  ├── traceroute/
  │   ├── plugin.json
  │   └── plugin.go
  └── ...

Creating a New Plugin

  1. Create a new directory for your plugin under app/plugins/plugins/:
mkdir -p app/plugins/plugins/my_plugin
  1. Create a plugin.json file that defines your plugin's metadata and parameters:
{
  "id": "my_plugin",
  "name": "My Plugin",
  "description": "Description of what your plugin does",
  "icon": "custom_icon",
  "parameters": [
    {
      "id": "param1",
      "name": "Parameter 1",
      "description": "Description of this parameter",
      "type": "string",
      "required": true,
      "default": "default value"
    },
    {
      "id": "param2",
      "name": "Parameter 2",
      "description": "Another parameter",
      "type": "number",
      "required": false,
      "default": 10,
      "min": 1,
      "max": 100,
      "step": 1
    }
  ]
}
  1. Create a plugin.go file that implements your plugin's functionality:
package my_plugin

import (
	"fmt"
	"time"
)

// Execute handles the plugin execution
func Execute(params map[string]interface{}) (interface{}, error) {
	// Get parameters
	param1, _ := params["param1"].(string)
	param2Raw, ok := params["param2"].(float64)
	if !ok {
		param2Raw = 10 // Default value
	}
	param2 := int(param2Raw)
	
	// Implement your plugin logic here
	result := map[string]interface{}{
		"param1": param1,
		"param2": param2,
		"result": "Your plugin's result",
		"timestamp": time.Now().Format(time.RFC3339),
	}
	
	return result, nil
}
  1. Update the getPluginExecuteFunc method in app/plugins/loader.go to include your new plugin:
func (pl *PluginLoader) getPluginExecuteFunc(pluginName string) (func(map[string]interface{}) (interface{}, error), error) {
	switch pluginName {
	// ... existing plugins ...
	case "my_plugin":
		return my_plugin.Execute, nil
	default:
		return nil, fmt.Errorf("plugin implementation not found: %s", pluginName)
	}
}
  1. Import your plugin in app/plugins/loader.go:
import (
	// ... existing imports ...
	"github.com/anoam/netscout-pi/app/plugins/plugins/my_plugin"
)

Parameter Types

The plugin system supports the following parameter types:

  • string: Text input
  • number: Numeric input with optional min/max/step
  • boolean: True/false checkbox
  • select: Dropdown selection with options
  • range: Range slider with min/max/step

Display Format

The frontend automatically formats the results based on the plugin ID. If you need a custom display format, you'll need to update:

  1. The JavaScript frontend in app/static/js/plugin-manager.js
  2. The plugin page template in app/templates/plugin_page.html

Testing Your Plugin

  1. Build and run the application
  2. Navigate to your plugin page at /plugin/my_plugin
  3. Configure the parameters and run the plugin
  4. Check the results and API response at /api/plugins/my_plugin/run

Documentation

Overview

Package plugins provides plugin execution with progress reporting and error handling.

Package plugins provides WebSocket streaming for plugin execution.

Package plugins provides modular network diagnostic plugins for NetScout-Go

Index

Constants

View Source
const (
	// Execution lifecycle messages
	MsgTypeExecutionStarted   = "execution_started"
	MsgTypeExecutionProgress  = "execution_progress"
	MsgTypeExecutionCompleted = "execution_completed"
	MsgTypeExecutionFailed    = "execution_failed"
	MsgTypeExecutionCancelled = "execution_cancelled"

	// Request messages from client
	MsgTypeCancelExecution    = "cancel_execution"
	MsgTypeGetExecutionStatus = "get_execution_status"
	MsgTypeSubscribe          = "subscribe"
	MsgTypeUnsubscribe        = "unsubscribe"
)

MessageType constants for WebSocket messages.

Variables

This section is empty.

Functions

func LoadPluginFunc

func LoadPluginFunc(pluginDir, pluginID string) (func(map[string]interface{}) (interface{}, error), error)

LoadPluginFunc loads the plugin function from a Go plugin file

Types

type BulkInstallResponse

type BulkInstallResponse struct {
	Results        []BulkInstallResult `json:"results"`
	TotalPlugins   int                 `json:"totalPlugins"`
	SuccessCount   int                 `json:"successCount"`
	FailureCount   int                 `json:"failureCount"`
	OverallSuccess bool                `json:"overallSuccess"`
}

BulkInstallResponse represents the response from bulk installation

type BulkInstallResult

type BulkInstallResult struct {
	PluginID string         `json:"pluginId"`
	Plugin   PluginMetadata `json:"plugin,omitempty"`
	Success  bool           `json:"success"`
	Error    string         `json:"error,omitempty"`
}

BulkInstallResult represents the result of a bulk installation

type Command

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

Command represents a shell command

func NewCommand

func NewCommand(cmd string) *Command

NewCommand creates a new command

func NewCommandWithArgs

func NewCommandWithArgs(cmd string, args ...string) *Command

NewCommandWithArgs creates a new command with arguments

func (*Command) Run

func (c *Command) Run() (string, error)

Run executes the command and returns its output

type ConfigManager

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

ConfigManager handles loading and saving plugin system configuration

func NewConfigManager

func NewConfigManager(configPath string) *ConfigManager

NewConfigManager creates a new configuration manager

func (*ConfigManager) AddGitHubToken

func (cm *ConfigManager) AddGitHubToken(name, token, organization string) error

AddGitHubToken adds a GitHub token to the configuration

func (*ConfigManager) AddSource

func (cm *ConfigManager) AddSource(name, organization, pattern string, isDefault bool) error

AddSource adds a plugin source to the configuration

func (*ConfigManager) GetConfiguration

func (cm *ConfigManager) GetConfiguration() *Configuration

GetConfiguration returns the current configuration

func (*ConfigManager) GetGitHubToken

func (cm *ConfigManager) GetGitHubToken(name string) (GitHubToken, error)

GetGitHubToken returns the GitHub token for the specified name

func (*ConfigManager) GetGitHubTokens

func (cm *ConfigManager) GetGitHubTokens() []GitHubToken

GetGitHubTokens returns all GitHub tokens

func (*ConfigManager) GetSources

func (cm *ConfigManager) GetSources() []PluginSource

GetSources returns all plugin sources

func (*ConfigManager) GetTokenForOrganization

func (cm *ConfigManager) GetTokenForOrganization(org string) (string, error)

GetTokenForOrganization returns a GitHub token for the specified organization

func (*ConfigManager) LoadConfiguration

func (cm *ConfigManager) LoadConfiguration() error

LoadConfiguration loads the configuration from the config file

func (*ConfigManager) RemoveGitHubToken

func (cm *ConfigManager) RemoveGitHubToken(name string) error

RemoveGitHubToken removes a GitHub token from the configuration

func (*ConfigManager) RemoveSource

func (cm *ConfigManager) RemoveSource(name string) error

RemoveSource removes a plugin source from the configuration

func (*ConfigManager) SaveConfiguration

func (cm *ConfigManager) SaveConfiguration() error

SaveConfiguration saves the configuration to the config file

func (*ConfigManager) SetLoadedCallback

func (cm *ConfigManager) SetLoadedCallback(callback func())

SetLoadedCallback sets a callback function to be called when the configuration is loaded

type Configuration

type Configuration struct {
	GitHub  GitHubConfig   `json:"github"`
	Sources []PluginSource `json:"sources"`
}

Configuration represents the main configuration structure

type Dependency

type Dependency struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Dependency represents a plugin dependency

type DynamicPlugin

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

DynamicPlugin represents a plugin that is executed dynamically

func (*DynamicPlugin) Execute

func (p *DynamicPlugin) Execute(params map[string]interface{}) (interface{}, error)

Execute runs the plugin with the given parameters

func (*DynamicPlugin) GetDefinition

func (p *DynamicPlugin) GetDefinition() types.PluginDefinition

GetDefinition returns the plugin definition

func (*DynamicPlugin) IsIterable

func (p *DynamicPlugin) IsIterable() bool

IsIterable checks if the plugin implements the IterablePlugin interface

type ExecutionContext

type ExecutionContext struct {
	ID       string
	PluginID string
	Params   map[string]interface{}
	Config   *types.PluginExecutionConfig
	// contains filtered or unexported fields
}

ExecutionContext provides context for a plugin execution.

func NewExecutionContext

func NewExecutionContext(pluginID string, params map[string]interface{}, config *types.PluginExecutionConfig) *ExecutionContext

NewExecutionContext creates a new execution context.

func (*ExecutionContext) AddProgressListener

func (ec *ExecutionContext) AddProgressListener(listener ProgressListener)

AddProgressListener adds a listener for progress updates.

func (*ExecutionContext) Cancel

func (ec *ExecutionContext) Cancel()

Cancel cancels the execution.

func (*ExecutionContext) Context

func (ec *ExecutionContext) Context() context.Context

Context returns the context for cancellation support.

func (*ExecutionContext) GetResult

func (ec *ExecutionContext) GetResult() *ExecutionResult

GetResult returns the current execution result.

func (*ExecutionContext) UpdateProgress

func (ec *ExecutionContext) UpdateProgress(current, total int, message string)

UpdateProgress updates the execution progress.

type ExecutionProgress

type ExecutionProgress struct {
	Current int    `json:"current"`
	Total   int    `json:"total"`
	Message string `json:"message"`
}

ExecutionProgress represents the progress of a plugin execution.

type ExecutionResult

type ExecutionResult struct {
	ID        string                 `json:"id"`
	PluginID  string                 `json:"pluginId"`
	Status    ExecutionStatus        `json:"status"`
	Progress  *ExecutionProgress     `json:"progress,omitempty"`
	Result    interface{}            `json:"result,omitempty"`
	Error     string                 `json:"error,omitempty"`
	StartTime time.Time              `json:"startTime"`
	EndTime   *time.Time             `json:"endTime,omitempty"`
	Duration  int64                  `json:"duration"` // in milliseconds
	Params    map[string]interface{} `json:"params"`
}

ExecutionResult represents the result of a plugin execution.

type ExecutionStatus

type ExecutionStatus string

ExecutionStatus represents the status of a plugin execution.

const (
	StatusPending   ExecutionStatus = "pending"
	StatusRunning   ExecutionStatus = "running"
	StatusCompleted ExecutionStatus = "completed"
	StatusFailed    ExecutionStatus = "failed"
	StatusCancelled ExecutionStatus = "cancelled"
)

type ExecutionStreamClient

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

ExecutionStreamClient represents a WebSocket client for plugin streaming.

func NewExecutionStreamClient

func NewExecutionStreamClient(conn *websocket.Conn) *ExecutionStreamClient

NewExecutionStreamClient creates a new streaming client.

func (*ExecutionStreamClient) IsSubscribed

func (c *ExecutionStreamClient) IsSubscribed(executionID string) bool

IsSubscribed checks if client is subscribed to an execution.

func (*ExecutionStreamClient) Send

Send sends a message to the client.

func (*ExecutionStreamClient) Subscribe

func (c *ExecutionStreamClient) Subscribe(executionID string)

Subscribe subscribes to an execution.

func (*ExecutionStreamClient) SubscribeAll

func (c *ExecutionStreamClient) SubscribeAll()

SubscribeAll subscribes to all executions.

func (*ExecutionStreamClient) Unsubscribe

func (c *ExecutionStreamClient) Unsubscribe(executionID string)

Unsubscribe unsubscribes from an execution.

type ExecutionStreamManager

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

ExecutionStreamManager manages WebSocket clients for execution streaming.

func NewExecutionStreamManager

func NewExecutionStreamManager(executor *PluginExecutor) *ExecutionStreamManager

NewExecutionStreamManager creates a new stream manager.

func (*ExecutionStreamManager) Broadcast

func (m *ExecutionStreamManager) Broadcast(executionID string, msg StreamMessage)

Broadcast sends a message to all subscribed clients.

func (*ExecutionStreamManager) CreateProgressListener

func (m *ExecutionStreamManager) CreateProgressListener(executionID string) ProgressListener

CreateProgressListener creates a progress listener for an execution.

func (*ExecutionStreamManager) ExecuteWithStreaming

func (m *ExecutionStreamManager) ExecuteWithStreaming(pluginID string, params map[string]interface{}, config *types.PluginExecutionConfig) (*ExecutionContext, error)

ExecuteWithStreaming executes a plugin with streaming progress updates.

func (*ExecutionStreamManager) HandleClientMessage

func (m *ExecutionStreamManager) HandleClientMessage(client *ExecutionStreamClient, rawMsg []byte)

HandleClientMessage processes incoming messages from a client.

func (*ExecutionStreamManager) RegisterClient

func (m *ExecutionStreamManager) RegisterClient(conn *websocket.Conn) *ExecutionStreamClient

RegisterClient registers a new WebSocket client.

func (*ExecutionStreamManager) UnregisterClient

func (m *ExecutionStreamManager) UnregisterClient(client *ExecutionStreamClient)

UnregisterClient removes a WebSocket client.

type GitHubConfig

type GitHubConfig struct {
	Tokens []GitHubToken `json:"tokens"`
}

GitHubConfig represents GitHub-specific configuration

type GitHubRepository

type GitHubRepository struct {
	Name        string `json:"name"`
	FullName    string `json:"full_name"`
	Description string `json:"description"`
	HTMLURL     string `json:"html_url"`
	CloneURL    string `json:"clone_url"`
	UpdatedAt   string `json:"updated_at"`
}

GitHubRepository represents a GitHub repository from the API

type GitHubToken

type GitHubToken struct {
	Name         string `json:"name"`
	Token        string `json:"token"`
	Organization string `json:"organization"`
}

GitHubToken represents a GitHub personal access token

type GitVersionInfo

type GitVersionInfo struct {
	CommitID       string `json:"commitID"`
	Branch         string `json:"branch"`
	LatestCommitID string `json:"latestCommitID,omitempty"`
	Repository     string `json:"repository,omitempty"`
	Organization   string `json:"organization,omitempty"`
}

GitVersionInfo represents Git version information for a plugin

type Option

type Option struct {
	Value interface{} `json:"value"`
	Label string      `json:"label"`
}

Option defines an option for a select parameter

type Parameter

type Parameter struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Type        ParameterType `json:"type"`
	Required    bool          `json:"required"`
	Default     interface{}   `json:"default,omitempty"`
	Options     []Option      `json:"options,omitempty"`    // For select type
	Min         *float64      `json:"min,omitempty"`        // For number/range type
	Max         *float64      `json:"max,omitempty"`        // For number/range type
	Step        *float64      `json:"step,omitempty"`       // For number/range type
	CanIterate  bool          `json:"canIterate,omitempty"` // Whether this parameter supports iteration
}

Parameter defines a plugin parameter

type ParameterType

type ParameterType string

ParameterType defines the type of a plugin parameter

const (
	// TypeString is the string type identifier.
	TypeString ParameterType = "string"
	// TypeNumber is the number type identifier.
	TypeNumber ParameterType = "number"
	// TypeBoolean is the boolean type identifier.
	TypeBoolean ParameterType = "boolean"
	// TypeSelect is the select type identifier.
	TypeSelect ParameterType = "select"
	// TypeRange is the range type identifier.
	TypeRange ParameterType = "range"
)

type Plugin

type Plugin struct {
	ID          string                                            `json:"id"`
	Name        string                                            `json:"name"`
	Description string                                            `json:"description"`
	Version     string                                            `json:"version"`
	Author      string                                            `json:"author"`
	License     string                                            `json:"license"`
	Icon        string                                            `json:"icon"`
	Parameters  []Parameter                                       `json:"parameters"`
	Execute     func(map[string]interface{}) (interface{}, error) `json:"-"`
}

Plugin represents a NetTool plugin

type PluginCatalog

type PluginCatalog struct {
	Plugins []PluginListItem `json:"plugins"`
}

PluginCatalog represents the catalog of available plugins

type PluginCatalogCache

type PluginCatalogCache struct {
	Plugins     []PluginListItem `json:"plugins"`
	LastUpdated int64            `json:"lastUpdated"` // Unix timestamp
	Source      string           `json:"source"`      // Source organization
}

PluginCatalogCache represents the cached plugin catalog with timestamp

type PluginDataJSON

type PluginDataJSON struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Version      string   `json:"version"`
	Author       string   `json:"author"`
	License      string   `json:"license"`
	Category     string   `json:"category"`
	Icon         string   `json:"icon"`
	Screenshots  []string `json:"screenshots"`
	Requirements []string `json:"requirements"`
	Tags         []string `json:"tags"`
	MinVersion   string   `json:"minVersion"`
	Homepage     string   `json:"homepage"`
}

PluginDataJSON represents the data.json structure in plugin repositories

type PluginExecutor

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

PluginExecutor handles enhanced plugin execution.

func NewPluginExecutor

func NewPluginExecutor(manager *PluginManager) *PluginExecutor

NewPluginExecutor creates a new plugin executor.

func (*PluginExecutor) CancelExecution

func (pe *PluginExecutor) CancelExecution(executionID string) error

CancelExecution cancels an execution by ID.

func (*PluginExecutor) CleanupOldExecutions

func (pe *PluginExecutor) CleanupOldExecutions(maxAge time.Duration) int

CleanupOldExecutions removes old completed executions.

func (*PluginExecutor) Execute

func (pe *PluginExecutor) Execute(pluginID string, params map[string]interface{}, config *types.PluginExecutionConfig) *ExecutionContext

Execute runs a plugin with enhanced execution context.

func (*PluginExecutor) ExecuteSync

func (pe *PluginExecutor) ExecuteSync(pluginID string, params map[string]interface{}) (*ExecutionResult, error)

ExecuteSync runs a plugin synchronously with enhanced error handling.

func (*PluginExecutor) GetActiveExecutions

func (pe *PluginExecutor) GetActiveExecutions() []*ExecutionResult

GetActiveExecutions returns all active executions.

func (*PluginExecutor) GetExecution

func (pe *PluginExecutor) GetExecution(executionID string) *ExecutionContext

GetExecution returns an execution context by ID.

type PluginInstaller

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

PluginInstaller handles installation, updates and uninstallation of plugins

func NewPluginInstaller

func NewPluginInstaller(pluginsDir string, manager *PluginManager) *PluginInstaller

NewPluginInstaller creates a new plugin installer

func (*PluginInstaller) AddPluginSource

func (pi *PluginInstaller) AddPluginSource(name, organization, pattern string) error

AddPluginSource adds a new plugin source organization

func (*PluginInstaller) BulkInstallPlugins

func (pi *PluginInstaller) BulkInstallPlugins(repositories []string) BulkInstallResponse

BulkInstallPlugins installs multiple plugins from a list of repositories

func (*PluginInstaller) CheckForUpdates

func (pi *PluginInstaller) CheckForUpdates(pluginID string) (bool, string)

CheckForUpdates checks if a plugin has updates available (exported version of checkForUpdates)

func (*PluginInstaller) GetPluginDetails

func (pi *PluginInstaller) GetPluginDetails(pluginID string) (PluginMetadata, error)

GetPluginDetails returns detailed information about a plugin

func (*PluginInstaller) GetPluginSources

func (pi *PluginInstaller) GetPluginSources() []PluginSource

GetPluginSources returns the list of plugin sources

func (*PluginInstaller) InstallFromGitHub

func (pi *PluginInstaller) InstallFromGitHub(org string, repo string, branch string) (PluginMetadata, error)

InstallFromGitHub installs a plugin from a GitHub repository in the specified organization

func (*PluginInstaller) InstallPlugin

func (pi *PluginInstaller) InstallPlugin(url string) (PluginMetadata, error)

InstallPlugin installs a plugin from a URL or Git repository

func (*PluginInstaller) InstallPluginFromRepository

func (pi *PluginInstaller) InstallPluginFromRepository(repository string) error

InstallPluginFromRepository installs a plugin from a GitHub repository

func (*PluginInstaller) ListAllGitHubPlugins

func (pi *PluginInstaller) ListAllGitHubPlugins() ([]map[string]interface{}, error)

ListAllGitHubPlugins lists available plugins from all registered organizations

func (*PluginInstaller) ListAvailablePlugins

func (pi *PluginInstaller) ListAvailablePlugins() ([]PluginListItem, error)

ListAvailablePlugins returns a list of available plugins from cache or GitHub

func (*PluginInstaller) ListAvailablePluginsWithMeta

func (pi *PluginInstaller) ListAvailablePluginsWithMeta(forceRefresh bool) (*PluginListResponse, error)

ListAvailablePluginsWithMeta returns plugins with metadata about cache status

func (*PluginInstaller) ListGitHubPlugins

func (pi *PluginInstaller) ListGitHubPlugins(org string) ([]map[string]interface{}, error)

ListGitHubPlugins lists available plugins from a GitHub organization

func (*PluginInstaller) ListInstalledPlugins

func (pi *PluginInstaller) ListInstalledPlugins() ([]PluginMetadata, error)

ListInstalledPlugins returns a list of installed plugins with metadata

func (*PluginInstaller) RefreshPluginCatalog

func (pi *PluginInstaller) RefreshPluginCatalog() (*PluginListResponse, error)

RefreshPluginCatalog forces a refresh of the plugin catalog from GitHub

func (*PluginInstaller) RemovePluginSource

func (pi *PluginInstaller) RemovePluginSource(organization string) error

RemovePluginSource removes a plugin source organization

func (*PluginInstaller) UninstallPlugin

func (pi *PluginInstaller) UninstallPlugin(pluginID string) (PluginMetadata, error)

UninstallPlugin uninstalls a plugin

func (*PluginInstaller) UpdatePlugin

func (pi *PluginInstaller) UpdatePlugin(pluginID string) (PluginMetadata, error)

UpdatePlugin updates a plugin to the latest version

func (*PluginInstaller) UpdateVersionInfo

func (pi *PluginInstaller) UpdateVersionInfo(pluginID string) error

UpdateVersionInfo updates the plugin.json file with the latest version information

func (*PluginInstaller) UploadPlugin

func (pi *PluginInstaller) UploadPlugin(file io.Reader) (PluginMetadata, error)

UploadPlugin installs a plugin from an uploaded ZIP file

type PluginListItem

type PluginListItem struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	Description  string                 `json:"description"`
	Version      string                 `json:"version"`
	Author       string                 `json:"author"`
	License      string                 `json:"license"`
	Category     string                 `json:"category"`
	Repository   string                 `json:"repository"`
	Icon         string                 `json:"icon"`
	Installed    bool                   `json:"installed"`
	DataJSON     map[string]interface{} `json:"dataJson,omitempty"`
	Screenshots  []string               `json:"screenshots,omitempty"`
	Requirements []string               `json:"requirements,omitempty"`
	Tags         []string               `json:"tags,omitempty"`
}

PluginListItem represents a plugin in the store listing

type PluginListResponse

type PluginListResponse struct {
	Plugins     []PluginListItem `json:"plugins"`
	LastUpdated int64            `json:"lastUpdated"`
	FromCache   bool             `json:"fromCache"`
}

PluginListResponse represents the response for listing available plugins

type PluginLoader

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

PluginLoader handles loading plugins from the filesystem

func NewPluginLoader

func NewPluginLoader(pluginsDir string) *PluginLoader

NewPluginLoader creates a new plugin loader

func (*PluginLoader) GetPluginExecuteFunc

func (p *PluginLoader) GetPluginExecuteFunc(pluginID string) (func(map[string]interface{}) (interface{}, error), error)

GetPluginExecuteFunc returns the Execute function for a plugin

func (*PluginLoader) LoadPlugins

func (p *PluginLoader) LoadPlugins() ([]types.Plugin, error)

LoadPlugins loads all plugins from the plugins directory

type PluginManager

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

PluginManager manages the plugins in NetTool

func NewPluginManager

func NewPluginManager() *PluginManager

NewPluginManager creates a new plugin manager

func (*PluginManager) GetPlugin

func (pm *PluginManager) GetPlugin(id string) (*Plugin, error)

GetPlugin returns a plugin by ID

func (*PluginManager) GetPlugins

func (pm *PluginManager) GetPlugins() []*Plugin

GetPlugins returns all registered plugins

func (*PluginManager) RefreshPlugins

func (pm *PluginManager) RefreshPlugins() error

RefreshPlugins refreshes the list of plugins from the plugins directory

func (*PluginManager) RegisterPlugin

func (pm *PluginManager) RegisterPlugin(plugin *Plugin)

RegisterPlugin registers a new plugin

func (*PluginManager) RegisterPlugins

func (pm *PluginManager) RegisterPlugins() error

RegisterPlugins refreshes and registers all plugins This is an alias for RefreshPlugins to maintain API compatibility with plugin_installer.go

func (*PluginManager) RunPlugin

func (pm *PluginManager) RunPlugin(id string, params map[string]interface{}) (interface{}, error)

RunPlugin runs a plugin with the given parameters

type PluginMetadata

type PluginMetadata struct {
	ID              string         `json:"id"`
	Name            string         `json:"name"`
	Description     string         `json:"description"`
	Version         string         `json:"version"`
	Author          string         `json:"author"`
	License         string         `json:"license"`
	Icon            string         `json:"icon"`
	Status          string         `json:"status"`
	UpdateAvailable bool           `json:"updateAvailable"`
	LatestVersion   string         `json:"latestVersion,omitempty"`
	Path            string         `json:"path,omitempty"`
	Dependencies    []Dependency   `json:"dependencies,omitempty"`
	GitInfo         GitVersionInfo `json:"gitInfo,omitempty"`
}

PluginMetadata represents the metadata of a plugin

type PluginRegistry

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

PluginRegistry is a simple registry for plugin execution functions

func GetRegistry

func GetRegistry() *PluginRegistry

GetRegistry returns the global plugin registry

func NewPluginRegistry

func NewPluginRegistry() *PluginRegistry

NewPluginRegistry creates a new plugin registry

func (*PluginRegistry) GetPluginFunc

func (r *PluginRegistry) GetPluginFunc(id string) (func(map[string]interface{}) (interface{}, error), error)

GetPluginFunc returns a plugin execution function

func (*PluginRegistry) RegisterPluginFunc

func (r *PluginRegistry) RegisterPluginFunc(id string, fn func(map[string]interface{}) (interface{}, error))

RegisterPluginFunc registers a plugin execution function

type PluginSource

type PluginSource struct {
	Name         string `json:"name"`
	Organization string `json:"organization"`
	IsDefault    bool   `json:"isDefault"`
	Pattern      string `json:"pattern"` // Naming pattern for plugins (e.g., "Plugin_*" or "plugin-*")
}

PluginSource represents a source for plugins

type ProgressListener

type ProgressListener func(result *ExecutionResult)

ProgressListener is called when execution progress updates.

type StreamMessage

type StreamMessage struct {
	Type        string      `json:"type"`
	ExecutionID string      `json:"executionId,omitempty"`
	PluginID    string      `json:"pluginId,omitempty"`
	Data        interface{} `json:"data,omitempty"`
	Error       string      `json:"error,omitempty"`
}

StreamMessage represents a WebSocket message for plugin execution.

Directories

Path Synopsis
Package cli provides command-line interface functionality for iterable plugins.
Package cli provides command-line interface functionality for iterable plugins.
Package types provides type definitions and compatibility helpers for plugins.
Package types provides type definitions and compatibility helpers for plugins.

Jump to

Keyboard shortcuts

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