plugins

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultRegistryHost = "registry.bluelink.dev"

DefaultRegistryHost is the default registry for plugins without an explicit host.

Variables

This section is empty.

Functions

func GetPluginsDir

func GetPluginsDir() string

GetPluginsDir returns the plugin installation directory. Priority: BLUELINK_DEPLOY_ENGINE_PLUGIN_PATH env var > default platform path. If BLUELINK_DEPLOY_ENGINE_PLUGIN_PATH contains multiple paths (separated by os.PathListSeparator), the first path is used for installation.

Directory structure:

  • {pluginsDir}/manifest.json - Plugin manifest tracking installed plugins
  • {pluginsDir}/bin/{namespace}/{name}/{version}/ - Plugin executables

Types

type DeployConfig

type DeployConfig struct {
	Dependencies map[string]string `json:"dependencies"`
}

DeployConfig represents the structure of bluelink.deploy.json.

func LoadDeployConfig

func LoadDeployConfig(path string) (*DeployConfig, error)

LoadDeployConfig loads a deploy config from the specified path.

func (*DeployConfig) GetPluginIDs

func (c *DeployConfig) GetPluginIDs() ([]*PluginID, error)

GetPluginIDs parses the dependencies and returns a list of PluginIDs.

type InstallResult

type InstallResult struct {
	PluginID *PluginID
	Status   InstallStatus
	Error    error
}

InstallResult contains the result of a plugin installation attempt.

type InstallStage

type InstallStage string

InstallStage represents the current stage of plugin installation.

const (
	StageResolving   InstallStage = "resolving"
	StageDownloading InstallStage = "downloading"
	StageVerifying   InstallStage = "verifying"
	StageExtracting  InstallStage = "extracting"
	StageComplete    InstallStage = "complete"
)

type InstallStatus

type InstallStatus int

InstallStatus represents the result status of a plugin installation.

const (
	StatusInstalled InstallStatus = iota
	StatusSkipped
	StatusFailed
)

type InstalledPlugin

type InstalledPlugin struct {
	ID           string            `json:"id"`
	Version      string            `json:"version"`
	RegistryHost string            `json:"registryHost"`
	Shasum       string            `json:"shasum"`
	InstalledAt  time.Time         `json:"installedAt"`
	Type         string            `json:"type,omitempty"`
	Dependencies map[string]string `json:"dependencies,omitempty"`
}

InstalledPlugin represents a plugin that has been installed.

type Manager

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

Manager handles plugin installation, verification, and manifest management.

func NewManager

func NewManager(
	registryClient *registries.RegistryClient,
	discoveryClient *registries.ServiceDiscoveryClient,
) *Manager

NewManager creates a new plugin manager.

func NewManagerWithPluginsDir

func NewManagerWithPluginsDir(
	registryClient *registries.RegistryClient,
	discoveryClient *registries.ServiceDiscoveryClient,
	pluginsDir string,
) *Manager

NewManagerWithPluginsDir creates a new plugin manager with a custom plugins directory.

func (*Manager) ExtractArchive

func (m *Manager) ExtractArchive(archivePath, destDir string) error

ExtractArchive extracts a tar.gz archive to the destination directory.

func (*Manager) GetMissingPlugins

func (m *Manager) GetMissingPlugins(pluginIDs []*PluginID) ([]*PluginID, error)

GetMissingPlugins returns plugins from the list that are not currently installed.

func (*Manager) GetUnsatisfiedPlugins

func (m *Manager) GetUnsatisfiedPlugins(pluginIDs []*PluginID) ([]*PluginID, error)

GetUnsatisfiedPlugins returns plugins from the list that are not installed or whose installed version does not satisfy the version requirement.

func (*Manager) Install

func (m *Manager) Install(
	ctx context.Context,
	pluginID *PluginID,
	progressFn ProgressCallback,
) (*InstallResult, error)

Installs a single plugin.

func (*Manager) InstallAll

func (m *Manager) InstallAll(
	ctx context.Context,
	pluginIDs []*PluginID,
	progressFn ProgressCallback,
) ([]*InstallResult, error)

InstallAll installs multiple plugins with dependency resolution. Dependencies are resolved and installed first in topological order.

func (*Manager) InstallMissing

func (m *Manager) InstallMissing(
	ctx context.Context,
	pluginIDs []*PluginID,
	progressFn ProgressCallback,
) ([]*InstallResult, error)

InstallMissing checks which plugins are not installed and installs them.

func (*Manager) IsInstalled

func (m *Manager) IsInstalled(pluginID *PluginID) (bool, *InstalledPlugin, error)

IsInstalled checks if a plugin is installed with the specified version.

func (*Manager) IsSatisfied

func (m *Manager) IsSatisfied(pluginID *PluginID) (bool, *InstalledPlugin, error)

IsSatisfied checks if a plugin requirement is met by an installed version. Unlike IsInstalled, this handles version constraints ("^1.0.0", "~1.0.0") and "latest" (any installed version satisfies).

func (*Manager) ListInstalled

func (m *Manager) ListInstalled() ([]*InstalledPlugin, error)

ListInstalled returns all installed plugins.

func (*Manager) LoadManifest

func (m *Manager) LoadManifest() (*PluginManifest, error)

LoadManifest loads the plugin manifest from disk.

func (*Manager) ResolveDependencies

func (m *Manager) ResolveDependencies(
	ctx context.Context,
	pluginIDs []*PluginID,
) ([]*PluginID, error)

ResolveDependencies resolves all dependencies for the given plugins and returns the full list in topological order (dependencies first, requested plugins last). Already-installed plugins are excluded from the result.

func (*Manager) ResolveLatestVersion

func (m *Manager) ResolveLatestVersion(ctx context.Context, pluginID *PluginID) (string, error)

ResolveLatestVersion finds the latest version of a plugin.

func (*Manager) ResolveVersion

func (m *Manager) ResolveVersion(ctx context.Context, pluginID *PluginID) (string, error)

ResolveVersion resolves the version for a plugin. If no version is specified, returns the latest version. If a constraint is specified (^1.0.0 or ~1.0.0), returns the best matching version. If an exact version is specified, returns that version.

func (*Manager) SaveManifest

func (m *Manager) SaveManifest(manifest *PluginManifest) error

SaveManifest saves the plugin manifest to disk.

func (*Manager) Uninstall

func (m *Manager) Uninstall(pluginID *PluginID) *UninstallResult

Uninstall removes a single plugin from the local machine.

func (*Manager) UninstallAll

func (m *Manager) UninstallAll(pluginIDs []*PluginID) []*UninstallResult

UninstallAll removes multiple plugins from the local machine.

func (*Manager) VerifyChecksum

func (m *Manager) VerifyChecksum(filePath string, shasums []byte, expectedFilename string) error

VerifyChecksum verifies the SHA256 checksum of a file against the shasums content.

func (*Manager) VerifyGPGSignature

func (m *Manager) VerifyGPGSignature(shasums, signature []byte, signingKeys map[string]string) error

VerifyGPGSignature verifies the GPG signature of the shasums file.

type PluginID

type PluginID struct {
	RegistryHost string // e.g., "registry.bluelink.dev" or "registry.example.com"
	Namespace    string // e.g., "bluelink", "my-org"
	Name         string // e.g., "aws", "gcp"
	Version      string // e.g., "1.0.0" or "" for latest
}

PluginID represents a parsed plugin identifier with registry, namespace, name, and version.

func ParsePluginID

func ParsePluginID(input string) (*PluginID, error)

ParsePluginID parses a plugin identifier string into a PluginID struct.

Supported formats:

  • "namespace/name" -> uses DefaultRegistryHost
  • "namespace/name@version" -> uses DefaultRegistryHost with version
  • "host/namespace/name" -> custom registry host
  • "host/namespace/name@version" -> custom registry host with version

func (*PluginID) FullyQualified

func (p *PluginID) FullyQualified() string

FullyQualified returns the fully qualified plugin ID including the registry host. Format: "host/namespace/name" or "host/namespace/name@version"

func (*PluginID) IsDefaultRegistry

func (p *PluginID) IsDefaultRegistry() bool

IsDefaultRegistry returns true if the plugin uses the default Bluelink registry.

func (*PluginID) IsVersionConstraint

func (p *PluginID) IsVersionConstraint() bool

IsVersionConstraint returns true if the version contains constraint prefixes (^ or ~).

func (*PluginID) ManifestKey

func (p *PluginID) ManifestKey() string

ManifestKey returns the key used to identify this plugin in the manifest file. This excludes the version since the manifest tracks installed versions separately. Format: "host/namespace/name"

func (*PluginID) ParseVersionConstraint

func (p *PluginID) ParseVersionConstraint() (*version.Constraint, error)

ParseVersionConstraint parses the version as a constraint. Returns an exact constraint if no prefix is present. Returns an error if no version is specified.

func (*PluginID) String

func (p *PluginID) String() string

String returns the short form of the plugin ID. For default registry: "namespace/name" or "namespace/name@version" For custom registry: "host/namespace/name" or "host/namespace/name@version"

func (*PluginID) WithVersion

func (p *PluginID) WithVersion(version string) *PluginID

WithVersion returns a copy of the PluginID with the specified version.

type PluginManifest

type PluginManifest struct {
	Plugins map[string]*InstalledPlugin `json:"plugins"`
}

PluginManifest tracks all installed plugins.

type ProgressCallback

type ProgressCallback func(pluginID *PluginID, stage InstallStage, downloaded, total int64)

ProgressCallback is called during installation to report progress.

type UninstallResult

type UninstallResult struct {
	PluginID *PluginID
	Status   UninstallStatus
	Error    error
}

UninstallResult contains the result of a plugin uninstallation attempt.

type UninstallStatus

type UninstallStatus int

UninstallStatus represents the result status of a plugin uninstallation.

const (
	UninstallStatusRemoved UninstallStatus = iota
	UninstallStatusNotFound
	UninstallStatusFailed
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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