Documentation
¶
Index ¶
- Constants
- func CompleteFunc(pluginPath string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func Exec(path string, args []string) error
- func ReadReceipt(pluginDir, name string) *plugintypes.Receipt
- func ResolvePlatform(pv *plugintypes.Version, goos, goarch string) (*plugintypes.Platform, error)
- func ResolveVersion(manifest *plugintypes.Manifest, version string) (*plugintypes.Version, error)
- func Uninstall(pluginDir, name string) error
- type CatalogClient
- type DigestMatch
- type Handler
- type Installer
- type Plugin
- type UpdateResult
Constants ¶
const ( SkipReasonManual = "manually installed" SkipReasonUpToDate = "already up to date" )
Variables ¶
This section is empty.
Functions ¶
func CompleteFunc ¶
func CompleteFunc(pluginPath string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
CompleteFunc returns a ValidArgsFunction that delegates completion to the plugin binary via Cobra's __complete protocol.
func Exec ¶
Exec replaces the current process with the plugin binary. This is what kubectl does — no signal forwarding or exit code propagation needed.
func ReadReceipt ¶
func ReadReceipt(pluginDir, name string) *plugintypes.Receipt
ReadReceipt reads the install receipt for a plugin. Returns nil if no receipt exists.
func ResolvePlatform ¶
func ResolvePlatform(pv *plugintypes.Version, goos, goarch string) (*plugintypes.Platform, error)
ResolvePlatform finds the platform entry matching the given OS and arch.
func ResolveVersion ¶
func ResolveVersion(manifest *plugintypes.Manifest, version string) (*plugintypes.Version, error)
ResolveVersion finds the requested version in the manifest. If version is empty, returns the first (latest) version.
Types ¶
type CatalogClient ¶
type CatalogClient struct {
// BaseURL is the catalog base URL for fetching manifests.
BaseURL string
// HTTPClient is the HTTP client used for catalog requests.
HTTPClient *http.Client
// GetEnv returns the value of an environment variable.
GetEnv func(key string) string
}
CatalogClient fetches plugin manifests and catalogs from a remote URL.
func NewCatalogClient ¶
func NewCatalogClient() *CatalogClient
NewCatalogClient returns a CatalogClient with production defaults.
func (*CatalogClient) FetchCatalog ¶
func (c *CatalogClient) FetchCatalog() (*plugintypes.Catalog, error)
FetchCatalog fetches the generated catalog.yaml.
func (*CatalogClient) FetchManifest ¶
func (c *CatalogClient) FetchManifest(name string) (*plugintypes.Manifest, error)
FetchManifest fetches a single plugin manifest from the catalog.
type DigestMatch ¶
type DigestMatch struct {
Version *plugintypes.Version
Platform *plugintypes.Platform
}
DigestMatch holds the version and platform resolved from a digest lookup.
func ResolveByDigest ¶
func ResolveByDigest(manifest *plugintypes.Manifest, digest, goos, goarch string) (*DigestMatch, error)
ResolveByDigest scans all versions and platforms for a checksum matching digest. The digest must be in "algorithm:hex" format (e.g. "sha256:06e0a38..."). Only platforms matching goos/goarch are considered. Returns the first match (versions are ordered newest-first in the manifest).
type Handler ¶
type Handler struct {
// ReadDir lists directory entries.
ReadDir func(name string) ([]os.DirEntry, error)
// Stat returns file info, following symlinks.
Stat func(name string) (os.FileInfo, error)
// GetEnv returns the value of an environment variable.
GetEnv func(key string) string
// HomeDir returns the current user's home directory.
HomeDir func() (string, error)
}
Handler discovers and executes plugins. Uses dependency injection for testability.
func (*Handler) Discover ¶
Discover scans the plugin directory for executables matching flux-*. It skips builtins, reserved names, directories, non-executable files, and broken symlinks.
func (*Handler) EnsurePluginDir ¶
EnsurePluginDir creates the plugin directory if it doesn't exist and returns the path. Best-effort — ignores mkdir errors for read-only filesystems. User-managed directories (via $FLUXCD_PLUGINS) are not auto-created.
type Installer ¶
type Installer struct {
// HTTPClient is the HTTP client used for downloading plugin archives.
HTTPClient *http.Client
}
Installer handles downloading, verifying, and installing plugins.
func NewInstaller ¶
func NewInstaller() *Installer
NewInstaller returns an Installer with production defaults.
func (*Installer) Install ¶
func (inst *Installer) Install(pluginDir string, manifest *plugintypes.Manifest, pv *plugintypes.Version, plat *plugintypes.Platform) error
Install downloads, verifies, extracts, and installs a plugin binary to the given plugin directory.
type Plugin ¶
type Plugin struct {
// Name is the plugin name, e.g. "operator" (derived from "flux-operator").
Name string
// Path is the absolute path to the plugin binary.
Path string
}
Plugin represents a discovered plugin binary.
type UpdateResult ¶
type UpdateResult struct {
// Name is the plugin name.
Name string
// FromVersion is the currently installed version.
FromVersion string
// ToVersion is the latest available version.
ToVersion string
// Skipped is true when the update was not performed.
Skipped bool
// SkipReason explains why the update was skipped.
SkipReason string
// Manifest is the resolved plugin manifest for the update.
Manifest *plugintypes.Manifest
// Version is the resolved target version for the update.
Version *plugintypes.Version
// Platform is the resolved platform entry for the update.
Platform *plugintypes.Platform
// Err is set when the update check itself failed.
Err error
}
UpdateResult represents the outcome of updating a single plugin. When an update is available, Manifest, Version and Platform are populated so the caller can install without re-fetching or re-resolving.
func CheckUpdate ¶
func CheckUpdate(pluginDir string, name string, catalog *CatalogClient, goos, goarch string) UpdateResult
CheckUpdate compares the installed version against the latest in the catalog. Returns an UpdateResult describing what should happen. When an update is available, Manifest is populated so the caller can install without re-fetching.