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 ¶
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 ¶
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 ¶
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 ¶
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.
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