plugins

package
v0.30.9 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package plugins implements the d8-cli plugin system.

A d8 plugin is a standalone binary published to an OCI Registry. It is not part of d8-cli and can be developed independently.

Why plugins exist

  • Isolate dependencies.
  • Enable independent, parallel development.
  • Let different teams own different plugins (delivery, system, ...).
  • Keep d8 itself compact, with only the dependencies it actually needs.

What d8-cli can do with plugins

  • Download them.
  • Validate their dependencies (requirements declared in contract.yaml that plugins declare).
  • Run them as if they were native subcommands.

Where a plugin lives

A plugin lives in an OCI Registry as a packaged file with a "contract" annotation. The annotation carries a base64-encoded JSON contract. Plugin metadata:

  • name;
  • version;
  • description;
  • environment variables;
  • flags;
  • requirements.

How a plugin invocation works

  1. The user invokes a command through d8.
  2. The parent CLI checks whether the plugin is installed.
  3. If it is not, the image is pulled from the registry.
  4. The binary is unpacked.
  5. Requirements are validated.
  6. A symlink is pointed at the current major version.
  7. The plugin is exec'd with the forwarded arguments.

What the plugin system is made of

  1. Discover - learn what plugins exist and what their contracts declare.
  2. Install - download and place the plugin in the right location with proper validation.
  3. Exec - run the plugin as part of d8 without losing argument context.

Index

Constants

View Source
const (
	SystemPluginName  = "system"
	PackagePluginName = "package"
)

Variables

This section is empty.

Functions

func NewCommand

func NewCommand(logger *dkplog.Logger) *cobra.Command

func NewPluginCommand

func NewPluginCommand(commandName, description string, aliases []string, logger *dkplog.Logger) *cobra.Command

TODO: add options pattern

Types

type FailedConstraints

type FailedConstraints map[string]*semver.Constraints

FailedConstraints holds plugin requirements that were not satisfied during installation: a nil value means the plugin is missing entirely, a non-nil value carries the constraint that the currently installed version fails.

type PluginsCommand

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

PluginsCommand holds shared state for every `d8 plugins ...` subcommand and is also reused by the per-plugin wrapper command (see plugin.go).

func NewPluginsCommand

func NewPluginsCommand(logger *dkplog.Logger) *PluginsCommand

func (*PluginsCommand) InitPluginServices

func (pc *PluginsCommand) InitPluginServices()

func (*PluginsCommand) InstallPlugin

func (pc *PluginsCommand) InstallPlugin(ctx context.Context, pluginName string, opts ...installPluginOption) error

InstallPlugin checks if plugin can be installed, creates folders layout and then installs plugin, creates symlink "current" and caches contract.json. version - semver version string (e.g. v1.0.0), default: "" (use latest version) useMajor - major version to install, default: -1 (use latest major version) resolvePluginsConflicts - resolve conflicts between installed plugins, default: false

Directories

Path Synopsis
Package flags defines the shared CLI flag set used by the d8 plugins management subcommands and consumed during registry client initialisation.
Package flags defines the shared CLI flag set used by the d8 plugins management subcommands and consumed during registry client initialisation.
Package layout centralizes the on-disk filesystem layout used by the d8 plugins subsystem: directory names, suffixes, and helpers that build concrete paths from the install root.
Package layout centralizes the on-disk filesystem layout used by the d8 plugins subsystem: directory names, suffixes, and helpers that build concrete paths from the install root.

Jump to

Keyboard shortcuts

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