extension

package
v1.0.40357-pre Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package extension implements the circleci plugin mechanism.

Any executable named "circleci-<name>" found in PATH is treated as an extension and can be invoked transparently as "circleci <name>". The extension receives CIRCLE_TOKEN, CIRCLE_HOST, and best-effort project metadata via environment variables so it can call the CircleCI API without reimplementing authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAll

func FindAll(path string) []string

FindAll scans PATH for executables named "circleci-<name>" and returns the extension names (the part after "circleci-"). The first entry in PATH wins for duplicate names, matching exec.LookPath semantics.

func NewCmd

func NewCmd(name string) *cobra.Command

NewCmd returns a cobra command that dispatches to the circleci-<name> extension. DisableFlagParsing is set so the extension receives its own args verbatim without cobra attempting to parse them. Root persistent flags (--config, --insecure-storage, etc.) are parsed separately from os.Args by ParseRootFlags so they are available for stream setup and auth injection without being forwarded to the extension.

func ParseRootFlags

func ParseRootFlags(cmd *cobra.Command) (extArgs []string)

ParseRootFlags populates the root command's persistent flags from os.Args for a command that sets DisableFlagParsing. Cobra never calls ParseFlags for such commands, so without this --theme, --debug, --quiet, --config, etc. would still hold their defaults when the root PersistentPreRunE sets up streams and loads config.

Parsing is non-interspersed, so it stops at the first positional argument (the extension name); flags after it belong to the extension and are returned verbatim along with any other trailing args.

func Run

func Run(ctx context.Context, client *apiclient.Client, name string, args []string) error

Run looks up circleci-<name> in PATH and execs it with args, injecting CircleCI environment variables. configPath is the --config flag value (empty means use the default XDG path). The current process is replaced by the extension via syscall exec on Unix; on Windows the extension is run as a child process and its exit code is propagated.

If no matching binary is found, ErrNotFound is returned and the caller should show the original "unknown command" error instead.

Types

type ErrExited

type ErrExited struct {
	Code int
}

ErrExited is returned by Run when the extension process exits with a non-zero status code. The caller should exit with Code rather than printing an error message — the extension is responsible for its own error output.

func (*ErrExited) Error

func (e *ErrExited) Error() string

type ErrNotFound

type ErrNotFound struct {
	Name string
}

ErrNotFound is returned when no circleci-<name> binary exists in PATH.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

Jump to

Keyboard shortcuts

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