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 ¶
- The user invokes a command through d8.
- The parent CLI checks whether the plugin is installed.
- If it is not, the image is pulled from the registry.
- The binary is unpacked.
- Requirements are validated.
- A symlink is pointed at the current major version.
- The plugin is exec'd with the forwarded arguments.
What the plugin system is made of ¶
- Discover - learn what plugins exist and what their contracts declare.
- Install - download and place the plugin in the right location with proper validation.
- Exec - run the plugin as part of d8 without losing argument context.
Index ¶
Constants ¶
const ( SystemPluginName = "system" PackagePluginName = "package" )
Variables ¶
This section is empty.
Functions ¶
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
Source Files
¶
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. |