Documentation
¶
Index ¶
- Constants
- type Binary
- type CachedReference
- type Config
- type ErrChecksumMismatch
- type ErrCorruptExtensionManifest
- type ErrDownloadFailed
- type ErrExited
- type ErrExtensionBinaryNotFound
- type ErrExtensionNotFound
- type ErrExtensionNotInstalled
- type ErrExtensionTooLarge
- type ErrInvalidName
- type ErrNoBinaryForPlatform
- type Extension
- type LatestData
- type Manager
- type Manifest
- type Reference
- type ReferenceArg
- type ReferenceCache
- type ReferenceFlag
- type ReferenceSub
- type Store
- type Unmanaged
Constants ¶
const NotInstalledAnnotation = "extension:not-installed"
NotInstalledAnnotation marks the placeholder command registered for an official extension that is not installed.
const ReferenceAnnotation = "extension:reference"
ReferenceAnnotation is the cobra command annotation key for when an extension provides reference documentation.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedReference ¶ added in v1.19.0
type CachedReference struct {
Version string `yaml:"version"`
FetchedAt time.Time `yaml:"fetched_at"`
// FailedAt is when a fetch last failed, zero once one succeeds. It holds
// off retrying, so an unreachable registry does not delay every start.
FailedAt time.Time `yaml:"failed_at,omitempty"`
Ref *Reference `yaml:"reference,omitempty"`
}
CachedReference is the registry's reference for an extension that is not installed, so its commands can be documented before the binary is downloaded.
type ErrChecksumMismatch ¶
ErrChecksumMismatch is returned when the downloaded binary does not match the expected SHA256.
func (*ErrChecksumMismatch) Error ¶
func (e *ErrChecksumMismatch) Error() string
type ErrCorruptExtensionManifest ¶
func (*ErrCorruptExtensionManifest) Error ¶
func (e *ErrCorruptExtensionManifest) Error() string
type ErrDownloadFailed ¶
type ErrDownloadFailed struct {
StatusCode int
}
ErrDownloadFailed is returned when the binary download returns a non-200 status.
func (*ErrDownloadFailed) Error ¶
func (e *ErrDownloadFailed) Error() string
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) ErrorCode ¶ added in v1.16.0
ErrorCode is the code telemetry records for an extension that exited non-zero.
func (*ErrExited) ExitStatus ¶ added in v1.16.0
ExitStatus is the status the CLI exits with: the extension's own code, or a general error when it has none to pass on — a negative Code means it was killed by a signal.
type ErrExtensionBinaryNotFound ¶
ErrExtensionBinaryNotFound is returned when the extension binary named in a manifest does not exist on disk
func (*ErrExtensionBinaryNotFound) Error ¶
func (e *ErrExtensionBinaryNotFound) Error() string
type ErrExtensionNotFound ¶
type ErrExtensionNotFound struct {
Name string
}
ErrExtensionNotFound is returned when the extension does not exist in the registry.
func (*ErrExtensionNotFound) Error ¶
func (e *ErrExtensionNotFound) Error() string
type ErrExtensionNotInstalled ¶
type ErrExtensionNotInstalled struct {
Name string
}
ErrExtensionNotInstalled is returned when attempting to remove an extension that is not installed.
func (*ErrExtensionNotInstalled) Error ¶
func (e *ErrExtensionNotInstalled) Error() string
type ErrExtensionTooLarge ¶
ErrExtensionTooLarge is returned when the decompressed extension binary exceeds the maximum allowed size.
func (*ErrExtensionTooLarge) Error ¶
func (e *ErrExtensionTooLarge) Error() string
type ErrInvalidName ¶
type ErrInvalidName struct {
Name string
}
ErrInvalidName is returned when the extension name contains invalid characters.
func (*ErrInvalidName) Error ¶
func (e *ErrInvalidName) Error() string
type ErrNoBinaryForPlatform ¶
ErrNoBinaryForPlatform is returned when the registry has no binary for the current OS/arch.
func (*ErrNoBinaryForPlatform) Error ¶
func (e *ErrNoBinaryForPlatform) Error() string
type LatestData ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
type Manifest ¶
type Manifest struct {
Name string `yaml:"name"`
BinaryName string `yaml:"binary_name"`
Version string `yaml:"version"`
Sha256 string `yaml:"sha256"`
URL string `yaml:"url"`
Path string `yaml:"path"`
Ref *Reference `yaml:"reference,omitempty"`
}
func (*Manifest) Run ¶
Run executes the extension binary with args, injecting CircleCI environment variables.
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 the extension binary is not found, ErrExtensionBinaryNotFound is returned and the caller should show prompt the user to reinstall the extension.
type Reference ¶
type Reference struct {
Use string `json:"use,omitempty" yaml:"use,omitempty"`
Short string `json:"short,omitempty" yaml:"short,omitempty"`
Long string `json:"long,omitempty" yaml:"long,omitempty"`
Args []ReferenceArg `json:"args,omitempty" yaml:"args,omitempty"`
Flags []ReferenceFlag `json:"flags,omitempty" yaml:"flags,omitempty"`
Subcommands []ReferenceSub `json:"subcommands,omitempty" yaml:"subcommands,omitempty"`
// Instructions tell an MCP client how to use the extension's tools. The
// server sends them when it serves those tools; empty means none.
Instructions string `json:"instructions,omitempty" yaml:"instructions,omitempty"`
}
Reference describes an extension command and, recursively, its subcommands. It is owned by the extension and fetched from the extension registry's release.json. When present, it enriches the CLI's generated reference docs; when absent, the CLI falls back to the base extension docs.
func LookupReference ¶ added in v1.19.0
LookupReference returns the reference documenting binaryName.
func (*Reference) SubcommandPath ¶ added in v1.16.0
SubcommandPath returns the declared subcommands that args start with, joined by spaces — "setup guide" for args "setup guide --json". It stops at the first arg that is not a subcommand the reference declares at that level, so a flag, a value or anything undeclared is never part of the result, and returns "" when the first arg is not one.
type ReferenceArg ¶
type ReferenceArg struct {
Name string `json:"name" yaml:"name"`
Help string `json:"help,omitempty" yaml:"help,omitempty"`
}
ReferenceArg describes a single argument for Reference.
type ReferenceCache ¶ added in v1.19.0
type ReferenceCache struct {
// contains filtered or unexported fields
}
ReferenceCache stores one CachedReference per extension, in a directory kept apart from the extensions directory so a cached reference is never mistaken for an installed extension.
func NewReferenceCache ¶ added in v1.19.0
func NewReferenceCache(dir string) *ReferenceCache
func (*ReferenceCache) Get ¶ added in v1.19.0
func (c *ReferenceCache) Get(binaryName string) (CachedReference, error)
Get returns the cached reference for binaryName, or the zero value when none has been cached.
func (*ReferenceCache) Put ¶ added in v1.19.0
func (c *ReferenceCache) Put(binaryName string, cached CachedReference) error
Put replaces the cached reference for binaryName. The file is written beside its destination and renamed into place, so a concurrent reader sees either the old reference or the new one, never a partial write.
type ReferenceFlag ¶
type ReferenceFlag struct {
Name string `json:"name" yaml:"name"`
Shorthand string `json:"shorthand,omitempty" yaml:"shorthand,omitempty"`
Usage string `json:"usage,omitempty" yaml:"usage,omitempty"`
// Type is the value placeholder shown after the flag name, e.g. "string".
// Empty means the flag takes no value (boolean-style).
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Default string `json:"default,omitempty" yaml:"default,omitempty"`
}
ReferenceFlag describes a single flag for Reference.
type ReferenceSub ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) FindAll ¶
FindAll scans path for extension manifest.yml files. It loads extension data from each manifest.yml and returns all loaded extension manifests.
type Unmanaged ¶
Unmanaged represents an extension not managed by the CLI.
func FindAllOnPATH ¶
func FindAllOnPATH() []Unmanaged
FindAllOnPATH 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 (*Unmanaged) Run ¶
Run executes the extension binary with args, injecting CircleCI environment variables.
The extension is run as a child process and its exit code is propagated via *ErrExited.
On SIGINT or SIGTERM the CLI keeps waiting so the extension can shut down cleanly, and kills it if it is still running after shutdownGrace or on a second signal. See superviseShutdown for which signals are forwarded.
If the extension binary is not found, ErrExtensionBinaryNotFound is returned and the caller should prompt the user to reinstall the extension.