plugins

package
v0.0.0-...-a0aaa14 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

FOR DB QUERIES

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInstalledPluginToDB

func AddInstalledPluginToDB(
	pluginDetailsID int,
	marketplacePluginID *int,
	userID int,
	installedMethod string,
	enabled bool,
	status string,
	installedPath string,
	loadTime int,
) (int, error)

func AddMarketplacePluginToDB

func AddMarketplacePluginToDB(
	pluginDetailsID int,
	featured bool,
	verified bool,
	priceType string,
	price float64,
	currency string,
	ratingAverage float64,
	ratingCount int,
	downloads int,
	activeInstalls int,
	publishedAt time.Time,
) error

func AddPluginFeedbackToDB

func AddPluginFeedbackToDB(marketplacePluginID, userID, rating int, comment string, suggessions string) error

func AddPluginToDB

func AddPluginToDB(
	name string,
	version string,
	description string,
	authorID int,
	website string,
	repository string,
	license string,
	tags []string,
	minVersion string,
	maxVersion string,
	dependencies []byte,
	s3Key string,
	fileSize int,
	isMarketplacePlugin bool,
) (int, error)

func BuildPluginKey

func BuildPluginKey(pluginName, author, version string) (string, error)

func CheckInstalledPluginWithID

func CheckInstalledPluginWithID(pluginID int) (bool, error)

func CheckInstalledPluginWithInfo

func CheckInstalledPluginWithInfo(pluginName, pluginVersion string, userID int) (bool, error)

func CheckPluginDetailsExist

func CheckPluginDetailsExist(pluginName, pluginVersion, pluginDescription string, authorID int, isMarketplacePlugin bool) (bool, error)

func CheckPluginDetailsExistByID

func CheckPluginDetailsExistByID(pluginID int) (bool, error)

func CheckPluginDetailsExistByNameAuthorVersion

func CheckPluginDetailsExistByNameAuthorVersion(pluginName string, authorID int, pluginVersion string) (bool, error)

func DeletePluginDetailsByID

func DeletePluginDetailsByID(pluginID int) error

func ExtractPluginPathID

func ExtractPluginPathID(s string) (int, error)

func GetAllMarketplacePlugins

func GetAllMarketplacePlugins() ([]*models.MarketplacePlugin, error)

func GetInstalledPluginId

func GetInstalledPluginId(pluginName, pluginVersion, pluginDescription string, authorID int, userID int) (int, error)

func GetMarketplacePluginByID

func GetMarketplacePluginByID(pluginID int) (*models.MarketplacePlugin, error)

func GetMarketplacePluginID

func GetMarketplacePluginID(pluginDetailsID int) (int, error)

func GetPluginDetailsByID

func GetPluginDetailsByID(pluginID int) (*models.PluginDetails, error)

func GetPluginDetailsID

func GetPluginDetailsID(pluginName, pluginVersion, pluginDescription string, authorID int) (int, error)

func GetPluginFeedback

func GetPluginFeedback(marketplacePluginID int) ([]models.PluginFeedback, error)

func GetPluginIDByNameAuthorVersion

func GetPluginIDByNameAuthorVersion(pluginName string, authorID int, pluginVersion string) (int, error)

func GetPluginIdDB

func GetPluginIdDB(pluginName, pluginVersion, pluginDescription string) (int, error)

func GetPluginStatusDB

func GetPluginStatusDB(pluginID int) (string, error)

func IncrementPluginDownloads

func IncrementPluginDownloads(pluginDetailsID int) error

func UninstallAllPluginFromDB

func UninstallAllPluginFromDB(pluginID int) error

func UninstallPluginFromDB

func UninstallPluginFromDB(pluginID int, userID int) error

func UpdateInstalledPluginInstalledPath

func UpdateInstalledPluginInstalledPath(installedPluginID int, installedPath string) error

func UpdatePluginStatusDB

func UpdatePluginStatusDB(pluginID int, status string, userID int) error

func UpdateRating

func UpdateRating(pluginDetailsID int, ratingAvg float32, ratingCnt int) error

Types

type APIBridge

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

APIBridge provides communication between plugins and external APIs

func NewAPIBridge

func NewAPIBridge(baseURL string, authToken string) *APIBridge

NewAPIBridge creates a new API bridge instance

func (*APIBridge) DeserializeRequest

func (ab *APIBridge) DeserializeRequest(data []byte) (*APIRequest, error)

DeserializeRequest deserializes an API request from JSON

func (*APIBridge) DeserializeResponse

func (ab *APIBridge) DeserializeResponse(data []byte) (*APIResponse, error)

DeserializeResponse deserializes an API response from JSON

func (*APIBridge) MakeInternalRequest

func (ab *APIBridge) MakeInternalRequest(ctx context.Context, method, path string, body []byte) (*APIResponse, error)

MakeInternalRequest makes a request to internal KubeStellar APIs

func (*APIBridge) MakeKubernetesRequest

func (ab *APIBridge) MakeKubernetesRequest(ctx context.Context, method, path string, body []byte) (*APIResponse, error)

MakeKubernetesRequest makes a request to the Kubernetes API

func (*APIBridge) MakeRequest

func (ab *APIBridge) MakeRequest(ctx context.Context, req *APIRequest) (*APIResponse, error)

MakeRequest executes an HTTP request on behalf of a plugin

func (*APIBridge) SerializeRequest

func (ab *APIBridge) SerializeRequest(req *APIRequest) ([]byte, error)

SerializeRequest serializes an API request to JSON

func (*APIBridge) SerializeResponse

func (ab *APIBridge) SerializeResponse(resp *APIResponse) ([]byte, error)

SerializeResponse serializes an API response to JSON

func (*APIBridge) ValidateRequest

func (ab *APIBridge) ValidateRequest(req *APIRequest) error

ValidateRequest validates an API request before execution

type APIRequest

type APIRequest struct {
	Method  string            `json:"method"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    []byte            `json:"body,omitempty"`
	Timeout int               `json:"timeout,omitempty"` // in seconds
}

APIRequest represents a request to be made by a plugin

type APIResponse

type APIResponse struct {
	StatusCode int               `json:"statusCode"`
	Headers    map[string]string `json:"headers"`
	Body       []byte            `json:"body"`
	Error      string            `json:"error,omitempty"`
}

APIResponse represents a response from an API call

type Plugin

type Plugin struct {
	ID       int                   `json:"id"`
	Manifest *PluginManifest       // Plugin metadata and configuration from plugin.yml
	Module   wazero.CompiledModule // Compiled WASM module
	Instance api.Module            // Instantiated WASM module
	Status   string                // Current status (e.g., active, inactive)
	LoadTime time.Time             // Timestamp when the plugin was loaded
}

Plugin represents a single loaded WASM plugin and its runtime details.

type PluginBackendConfig

type PluginBackendConfig struct {
	Enabled bool          `yaml:"enabled" json:"enabled"`                   // Whether backend is enabled
	Routes  []PluginRoute `yaml:"routes,omitempty" json:"routes,omitempty"` // Backend API routes
}

PluginBackendConfig contains backend integration configuration

type PluginBuildConfig

type PluginBuildConfig struct {
	GoVersion     string `yaml:"go_version" json:"go_version"`         // Go version used for building
	TinyGoVersion string `yaml:"tinygo_version" json:"tinygo_version"` // TinyGo version used for WASM compilation
}

PluginBuildConfig contains build information

type PluginConfigItem

type PluginConfigItem struct {
	Name        string      `yaml:"name" json:"name"`               // Configuration name
	Type        string      `yaml:"type" json:"type"`               // Type (e.g., "integer", "string")
	Default     interface{} `yaml:"default" json:"default"`         // Default value
	Description string      `yaml:"description" json:"description"` // Description of the configuration
}

PluginConfigItem describes a configuration option

type PluginFrontendConfig

type PluginFrontendConfig struct {
	Enabled    bool                   `yaml:"enabled" json:"enabled"`                           // Whether frontend integration is enabled
	Navigation []PluginNavigationItem `yaml:"navigation,omitempty" json:"navigation,omitempty"` // Navigation integration
	Widgets    []PluginWidgetConfig   `yaml:"widgets,omitempty" json:"widgets,omitempty"`       // Dashboard widgets
	Routes     []PluginFrontendRoute  `yaml:"routes,omitempty" json:"routes,omitempty"`         // Frontend routes
}

PluginFrontendConfig contains frontend integration configuration

type PluginFrontendRoute

type PluginFrontendRoute struct {
	Path      string `yaml:"path" json:"path"`           // Route path
	Component string `yaml:"component" json:"component"` // React component name
	Exact     bool   `yaml:"exact" json:"exact"`         // Whether route matching should be exact
}

PluginFrontendRoute describes a frontend route definition

type PluginInfo

type PluginInfo struct {
	ID           int       `json:"id"`
	Name         string    `json:"name"`
	Version      string    `json:"version"`
	Author       string    `json:"author,omitempty"`
	Description  string    `json:"description,omitempty"`
	Path         string    `json:"path"`
	ManifestPath string    `json:"manifestPath"`
	WasmPath     string    `json:"wasmPath"`
	DiscoveredAt time.Time `json:"discoveredAt"`
	LastModified time.Time `json:"lastModified"`
	Status       string    `json:"status"` // "discovered", "loaded", "error"
	Error        string    `json:"error,omitempty"`
}

PluginInfo contains metadata about a discovered plugin

type PluginLoader

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

PluginLoader handles plugin loading, validation, and integrity checking

func NewPluginLoader

func NewPluginLoader(pluginsDirectory string) *PluginLoader

NewPluginLoader creates a new plugin loader

func (*PluginLoader) LoadPluginFromArchive

func (pl *PluginLoader) LoadPluginFromArchive(archivePath string) (*Plugin, error)

LoadPluginFromArchive loads a plugin from a compressed archive

func (*PluginLoader) LoadPluginFromPath

func (pl *PluginLoader) LoadPluginFromPath(pluginPath string) (*Plugin, error)

LoadPluginFromPath loads a plugin from a specific path

func (*PluginLoader) ValidatePlugin

func (pl *PluginLoader) ValidatePlugin(pluginPath string) (*PluginValidationResult, error)

ValidatePlugin validates a plugin without loading it

type PluginManager

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

PluginManager handles the lifecycle, runtime, and routing of dynamically loaded plugins.

func NewPluginManager

func NewPluginManager(router *gin.Engine) *PluginManager

NewPluginManager initializes a new PluginManager with wazero runtime and Gin router.

func (*PluginManager) DeregisterPlugin

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

func (*PluginManager) DisablePlugin

func (pm *PluginManager) DisablePlugin(pluginID int, userID int) error

func (*PluginManager) EnablePlugin

func (pm *PluginManager) EnablePlugin(pluginID int, userID int) error

func (*PluginManager) GetPlugin

func (pm *PluginManager) GetPlugin(id int) (*Plugin, bool)

GetPlugin retrieves a specific plugin by name.

func (*PluginManager) GetPluginList

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

GetPluginList returns all registered plugins.

func (*PluginManager) GetRegisteredRoutes

func (pm *PluginManager) GetRegisteredRoutes(pluginID int) []string

GetRegisteredRoutes returns the list of registered routes for a plugin

func (*PluginManager) IsPluginDisabled

func (pm *PluginManager) IsPluginDisabled(id int) bool

IsPluginDisabled checks if a plugin is disabled

func (*PluginManager) LoadPlugin

func (pm *PluginManager) LoadPlugin(pluginPath string) error

LoadPlugin loads and initializes a plugin from a given directory.

func (*PluginManager) RegisterPlugin

func (pm *PluginManager) RegisterPlugin(plugin *Plugin, userIDAuth int)

func (*PluginManager) UninstallAllPlugins

func (pm *PluginManager) UninstallAllPlugins() error

func (*PluginManager) UnloadPlugin

func (pm *PluginManager) UnloadPlugin(pluginID int) error

UnloadPlugin terminates and removes a plugin from the manager.

type PluginManifest

type PluginManifest struct {
	APIVersion string         `yaml:"apiVersion" json:"apiVersion"` // API version
	Kind       string         `yaml:"kind" json:"kind"`             // Resource kind (e.g., "Plugin")
	Metadata   PluginMetadata `yaml:"metadata" json:"metadata"`     // Plugin metadata
	Spec       PluginSpec     `yaml:"spec" json:"spec"`             // Plugin specification
}

PluginManifest defines the plugin.yml schema for plugin configuration.

type PluginMetadata

type PluginMetadata struct {
	Name        string `yaml:"name" json:"name"`               // Unique name of the plugin
	Version     string `yaml:"version" json:"version"`         // Plugin version
	Author      string `yaml:"author" json:"author"`           // Plugin author
	Description string `yaml:"description" json:"description"` // Plugin description
}

PluginMetadata defines the plugin metadata information

type PluginNavigationItem

type PluginNavigationItem struct {
	Label    string `yaml:"label" json:"label"`       // Display label
	Icon     string `yaml:"icon" json:"icon"`         // Icon identifier
	Path     string `yaml:"path" json:"path"`         // Route path
	Position string `yaml:"position" json:"position"` // Position in menu (e.g., "main")
	Order    int    `yaml:"order" json:"order"`       // Display order
}

PluginNavigationItem describes a navigation menu item

type PluginRegistry

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

PluginRegistry handles plugin discovery, registration, and lifecycle management

func NewPluginRegistry

func NewPluginRegistry(pluginsDirectory string, manager *PluginManager) *PluginRegistry

NewPluginRegistry creates a new plugin registry

func (*PluginRegistry) DiscoverPlugins

func (pr *PluginRegistry) DiscoverPlugins() ([]*PluginInfo, error)

DiscoverPlugins scans the plugins directory for available plugins

func (*PluginRegistry) GetPluginInfo

func (pr *PluginRegistry) GetPluginInfo(name string) (*PluginInfo, error)

GetPluginInfo returns information about a specific plugin

func (*PluginRegistry) GetPluginsDirectory

func (pr *PluginRegistry) GetPluginsDirectory() string

GetPluginsDirectory returns the plugins directory path

func (*PluginRegistry) LoadPlugin

func (pr *PluginRegistry) LoadPlugin(name string) error

LoadPlugin loads a plugin by name

func (*PluginRegistry) ReloadPlugin

func (pr *PluginRegistry) ReloadPlugin(pluginID int) error

ReloadPlugin reloads a plugin by name

func (*PluginRegistry) StartWatching

func (pr *PluginRegistry) StartWatching() error

StartWatching starts the plugin watcher for hot reloading

func (*PluginRegistry) StopWatching

func (pr *PluginRegistry) StopWatching() error

StopWatching stops the plugin watcher

func (*PluginRegistry) UnloadPlugin

func (pr *PluginRegistry) UnloadPlugin(ID int) error

UnloadPlugin unloads a plugin by ID

type PluginRoute

type PluginRoute struct {
	Path    string   `yaml:"path" json:"path"`       // Route path (e.g., "/status")
	Methods []string `yaml:"methods" json:"methods"` // HTTP methods
	Handler string   `yaml:"handler" json:"handler"` // Name of the WASM function to call
}

PluginRoute describes a single HTTP route exposed by a plugin.

type PluginSpec

type PluginSpec struct {
	Wasm          *PluginWasmConfig     `yaml:"wasm,omitempty" json:"wasm,omitempty"`                   // WASM binary configuration
	Build         *PluginBuildConfig    `yaml:"build,omitempty" json:"build,omitempty"`                 // Build configuration
	Backend       *PluginBackendConfig  `yaml:"backend,omitempty" json:"backend,omitempty"`             // Backend configuration
	Permissions   []string              `yaml:"permissions,omitempty" json:"permissions,omitempty"`     // Required permissions
	Frontend      *PluginFrontendConfig `yaml:"frontend,omitempty" json:"frontend,omitempty"`           // Frontend configuration
	Configuration []PluginConfigItem    `yaml:"configuration,omitempty" json:"configuration,omitempty"` // Plugin configuration options
}

PluginSpec contains the plugin specification

type PluginValidationResult

type PluginValidationResult struct {
	Valid    bool     `json:"valid"`
	Errors   []string `json:"errors,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
	Checksum string   `json:"checksum,omitempty"`
	Size     int64    `json:"size,omitempty"`
}

PluginValidationResult contains the result of plugin validation

type PluginWasmConfig

type PluginWasmConfig struct {
	File        string `yaml:"file" json:"file"`                 // WASM file name
	Entrypoint  string `yaml:"entrypoint" json:"entrypoint"`     // Main function entry point
	MemoryLimit string `yaml:"memory_limit" json:"memory_limit"` // Memory limit (e.g., "64MB")
}

PluginWasmConfig contains WASM binary information

type PluginWatcher

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

PluginWatcher monitors the plugins directory for changes and automatically reloads plugins

func NewPluginWatcher

func NewPluginWatcher(registry *PluginRegistry) *PluginWatcher

NewPluginWatcher creates a new plugin watcher

func (*PluginWatcher) Start

func (pw *PluginWatcher) Start() error

Start begins watching the plugins directory for changes

func (*PluginWatcher) Stop

func (pw *PluginWatcher) Stop() error

Stop stops the plugin watcher

type PluginWidgetConfig

type PluginWidgetConfig struct {
	Name      string `yaml:"name" json:"name"`           // Widget name
	Title     string `yaml:"title" json:"title"`         // Widget title
	Size      string `yaml:"size" json:"size"`           // Widget size (e.g., "medium")
	Dashboard string `yaml:"dashboard" json:"dashboard"` // Target dashboard
	Component string `yaml:"component" json:"component"` // React component name
}

PluginWidgetConfig describes a dashboard widget

Jump to

Keyboard shortcuts

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