plugin

package
v1.223.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureForComponent

func EnsureForComponent(ctx context.Context, helmBin string, rawSpecs []string) (string, error)

EnsureForComponent parses the raw plugin declarations and installs any that are missing, returning the managed HELM_PLUGINS directory.

When no plugins are declared it returns an empty string so callers leave HELM_PLUGINS untouched, preserving the user's default Helm plugin behavior.

func ExtractSpecs

func ExtractSpecs(section map[string]any) []string

ExtractSpecs reads the `plugins` section from a component configuration map and returns the declared plugin specs as strings. Non-string entries are coerced with fmt so templated values render predictably. Returns nil when the section is absent or empty.

func KnownAliases

func KnownAliases() []string

KnownAliases returns the sorted list of built-in plugin aliases. Used to build helpful error hints when an unknown alias is supplied.

func ManagedDir

func ManagedDir() string

ManagedDir returns the default managed HELM_PLUGINS directory, derived from the toolchain install path.

The path is resolved to absolute: helmfile runs helm from the component's working directory, so a HELM_PLUGINS value relative to the Atmos base directory (e.g. a configured `.tools`) would not resolve there and helm would fail to find installed plugins like helm-diff. This mirrors how toolchain binary PATH entries are absolutized (see pkg/dependencies/environment.go).

Types

type InstalledPlugin

type InstalledPlugin struct {
	Name    string
	Version string
}

InstalledPlugin describes a plugin reported by `helm plugin list`.

type Installer

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

Installer installs and inspects Helm plugins in an Atmos-managed directory.

func NewInstaller

func NewInstaller(helmBin string, opts ...Option) *Installer

NewInstaller creates an Installer for the given helm binary path.

func (*Installer) EnsurePlugins

func (i *Installer) EnsurePlugins(ctx context.Context, specs []Spec) (string, error)

EnsurePlugins makes sure every spec is installed at the requested version in the managed directory and returns that directory (suitable for HELM_PLUGINS).

Already-satisfied plugins are skipped. A plugin present at a different pinned version is reinstalled to honor the declared version.

func (*Installer) ListInstalled

func (i *Installer) ListInstalled(ctx context.Context) (map[string]string, error)

ListInstalled returns the plugins currently installed in the managed directory, keyed by plugin name.

type Option

type Option func(*Installer)

Option configures an Installer.

func WithDir

func WithDir(dir string) Option

WithDir overrides the managed plugins directory (used in tests).

func WithRunner

func WithRunner(r Runner) Option

WithRunner overrides the subprocess runner (used in tests).

type Runner

type Runner interface {
	// Run executes name with args. extraEnv entries (KEY=VALUE) are appended to
	// the current environment. It returns combined stdout and stderr separately.
	Run(ctx context.Context, name string, args, extraEnv []string) (stdout, stderr string, err error)
}

Runner abstracts subprocess execution so the installer can be unit-tested without a real helm binary.

type Spec

type Spec struct {
	// Name is a human-friendly label for the plugin (the alias or repo name),
	// used in log/UI messages.
	Name string
	// URL is the install URL passed to `helm plugin install`.
	URL string
	// Version is a concrete tag/ref (e.g. "v3.9.4") or empty / "latest" to
	// install the latest released version.
	Version string
	// Raw is the original, unparsed declaration.
	Raw string
}

Spec is a parsed Helm plugin declaration.

It is produced from a compact string in one of the following forms:

func ParseSpec

func ParseSpec(raw string) (Spec, error)

ParseSpec parses a single compact plugin declaration into a Spec.

func ParseSpecs

func ParseSpecs(raws []string) ([]Spec, error)

ParseSpecs parses a list of compact plugin declarations.

func (Spec) IsLatest

func (s Spec) IsLatest() bool

IsLatest reports whether the spec requests the latest version (no pinned tag).

Jump to

Keyboard shortcuts

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