plugin

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 5 Imported by: ? 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

Overview

Package plugin implements dtctl's kubectl-style exec plugin convention: an executable named dtctl-<name> on PATH extends dtctl with the `dtctl <name>` command. This package only resolves and discovers plugins; dispatch (the exec) lives in cmd, and built-in commands always win because dispatch is only attempted for names cobra does not know.

See docs/dev/PLUGIN_CONVENTIONS.md for the author-facing contract.

Index

Constants

View Source
const Prefix = "dtctl-"

Prefix is the file-name prefix that marks an executable as a dtctl plugin.

Variables

This section is empty.

Functions

This section is empty.

Types

type Invocation

type Invocation struct {
	// CommandWords are the argv words consumed by the plugin name,
	// e.g. ["foo", "bar"] for dtctl-foo-bar.
	CommandWords []string
	// Path is the resolved binary path.
	Path string
	// Args are the remaining arguments to pass to the plugin.
	Args []string
}

Invocation is a resolved plugin call.

func Resolve

func Resolve(words, rest []string, lookPath func(string) (string, error)) (*Invocation, bool)

Resolve maps leading command words to the longest matching dtctl-<a-b-c> binary on PATH (kubectl semantics): words [foo bar baz] tries dtctl-foo-bar-baz, then dtctl-foo-bar (arg baz), then dtctl-foo (args bar baz). rest is appended after the unconsumed words. lookPath is exec.LookPath in production; injected for tests.

A candidate name containing a path separator is never looked up: a separator would turn the name into a relative path, and exec.LookPath resolves those against the working directory without the ErrDot guard that otherwise keeps dispatch off cwd-relative binaries. Shorter separator-free prefixes still resolve, so a path may appear as a plugin argument (`dtctl foo some/file.yaml`), just never in the plugin name.

type Plugin

type Plugin struct {
	Name    string `json:"name" yaml:"name" table:"NAME"`
	Binary  string `json:"binary" yaml:"binary" table:"BINARY"`
	Path    string `json:"path" yaml:"path" table:"PATH"`
	Warning string `json:"warning,omitempty" yaml:"warning,omitempty" table:"WARNING"`
}

Plugin is a plugin binary discovered on PATH.

func Discover

func Discover(pathEnv string, builtins map[string]bool) []Plugin

Discover scans the directories of pathEnv (a PATH-formatted list) for dtctl-* executables. The first occurrence of a binary name on PATH wins, matching exec semantics. builtins is the set of built-in dtctl command names (including aliases); a plugin whose first command word collides gets a Warning, because built-ins always win at dispatch time.

Jump to

Keyboard shortcuts

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