Documentation
¶
Overview ¶
Package setup provides initialisation helpers for GTB-based tools, including configuration directory bootstrapping, default config file creation, and self-update orchestration.
The Initialiser interface supports a modular hook-based pattern for extending the init process — SSH key setup, authentication configuration, and custom post-init steps can be composed and ordered. Update checks use semantic version comparison against the configured release source (GitHub or GitLab).
Package setup provides self-update and bootstrap functionality for GTB-based tools. This file registers all built-in release providers via blank imports so that they are available whenever pkg/setup is imported.
Index ¶
- Constants
- Variables
- func Chain(feature props.FeatureCmd, runE func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error
- func FeatureOf(cmd *cobra.Command) props.FeatureCmd
- func GetCheckedVersion(fs afero.Fs, name string) string
- func GetChecks() map[props.FeatureCmd][]CheckProvider
- func GetDefaultConfigDir(_ afero.Fs, name string) string
- func GetFeatureFlags() map[props.FeatureCmd][]FeatureFlag
- func GetInitialisers() map[props.FeatureCmd][]InitialiserProvider
- func GetSubcommands() map[props.FeatureCmd][]SubcommandProvider
- func GetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) time.Duration
- func Initialise(props *props.Props, opts InitOptions) (string, error)
- func IsExposedToMCP(cmd *cobra.Command) bool
- func IsSealed() bool
- func Register(feature props.FeatureCmd, ips []InitialiserProvider, sps []SubcommandProvider, ...)
- func RegisterChecks(feature props.FeatureCmd, cps []CheckProvider)
- func RegisterGlobalMiddleware(mw ...Middleware)
- func RegisterMiddleware(feature props.FeatureCmd, mw ...Middleware)
- func ResetRegistryForTesting()
- func ResolveCheckInterval(toolDefault time.Duration, configValue string) time.Duration
- func Seal()
- func SealRegistry()
- func SetCheckedVersion(fs afero.Fs, name, version string) error
- func SetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) error
- func SkipUpdateCheck(fs afero.Fs, name string, cmd *cobra.Command, checkInterval time.Duration) bool
- func VerifyChecksum(fs afero.Fs, sidecarPath string, data []byte) error
- func VerifyChecksumFromManifest(manifest []byte, filename string, data []byte) error
- func VerifyChecksumFromManifestReader(manifest []byte, filename string, dataReader io.Reader, dst io.Writer, ...) (int64, error)
- type CheckFunc
- type CheckProvider
- type CheckResult
- type Command
- type FeatureFlag
- type FeatureRegistry
- type InitOptions
- type Initialiser
- type InitialiserProvider
- type MCPExposure
- type Middleware
- type SelfUpdater
- func (s *SelfUpdater) DownloadAsset(ctx context.Context, asset release.ReleaseAsset) (bytes.Buffer, error)
- func (s *SelfUpdater) GetCurrentVersion() string
- func (s *SelfUpdater) GetLatestRelease(ctx context.Context) (release.Release, error)
- func (s *SelfUpdater) GetLatestVersionString(ctx context.Context) (string, error)
- func (s *SelfUpdater) GetReleaseNotes(ctx context.Context, from string, to string) (string, error)
- func (s *SelfUpdater) GetStructuredReleaseNotes(ctx context.Context, from, to string, archive ...bytes.Buffer) (*changelog.Changelog, error)
- func (s *SelfUpdater) IsLatestVersion(ctx context.Context) (bool, string, error)
- func (s *SelfUpdater) SignatureAssetName() string
- func (s *SelfUpdater) Update(ctx context.Context) (string, error)
- func (s *SelfUpdater) UpdateFromFile(filePath string) (string, error)
- type SubcommandProvider
- type UpdaterOption
- func WithEmbeddedKeys(armoredKeys ...[]byte) UpdaterOption
- func WithExecLookPath(fn func(string) (string, error)) UpdaterOption
- func WithKeyResolver(r verify.KeyResolver) UpdaterOption
- func WithOsExecutable(fn func() (string, error)) UpdaterOption
- func WithReleaseProvider(p release.Provider) UpdaterOption
Constants ¶
const ( UpdatedKey = timeSinceKey("updated") CheckedKey = timeSinceKey("checked") )
const DefaultCheckInterval = defaultCheckInterval
DefaultCheckInterval is the update-check throttle used when `update.check_interval` is unset or invalid.
const (
DefaultConfigFilename = "config.yaml"
)
const FeatureAnnotation = "gtb.feature"
FeatureAnnotation is the cobra.Command.Annotations key under which Wrap records the feature a command belongs to. Code that only has the raw *cobra.Command (e.g. a PersistentPreRunE hook) can identify the command by feature via FeatureOf instead of matching the fragile Use string.
const MCPExposureAnnotation = "gtb.mcp.exposure"
MCPExposureAnnotation is the cobra.Command.Annotations key under which a command's explicit MCP-exposure decision is recorded. It mirrors FeatureAnnotation. The value is [mcpExposureValueExposed] or [mcpExposureValueExcluded]; the key is absent when the command inherits.
Variables ¶
var ( // MaxChecksumsSize caps the byte length of a downloaded checksums // manifest. A GoReleaser manifest for a typical multi-OS release // is ~1 KiB; 1 MiB is 1000× headroom. MaxChecksumsSize int64 = 1 << 20 // MaxBinaryDownloadSize caps the byte length of a downloaded // binary asset. 512 MiB is far above any realistic CLI binary; // raise this only for tools that legitimately ship larger artefacts. MaxBinaryDownloadSize int64 = 512 << 20 )
Size bounds on untrusted inputs. Exported as variables so tools with exceptional release layouts can reassign them before calling Update; the defaults are generous but protect against a hostile server streaming an unbounded response.
var DefaultConfig []byte
var DefaultRequireChecksum = false
DefaultRequireChecksum is the compile-time default for checksum enforcement when neither config nor env var provides one. Tool authors should set this to true in main() for security-critical tools that want fail-closed verification from day one.
var ErrBinaryNotInArchive = errors.New("expected binary not found in archive")
ErrBinaryNotInArchive is returned when the release archive does not contain a binary matching the tool name. Without this, extraction silently reported success while leaving the old binary in place.
var ErrBinaryTooLarge = errors.New("binary download exceeds maximum size")
ErrBinaryTooLarge is returned when a downloaded release binary exceeds MaxBinaryDownloadSize. Indicates a hostile or misbehaving server.
var ErrChecksumAssetNotFound = errors.New("asset not found in checksums manifest")
ErrChecksumAssetNotFound is returned when the target filename is not listed in the checksums manifest. The release may have been created without GoReleaser or with a non-default checksums layout.
var ErrChecksumManifestDuplicate = errors.New("checksums manifest contains a duplicate filename")
ErrChecksumManifestDuplicate is returned when a filename appears more than once in the checksums manifest. A duplicate entry is ambiguous — silently letting the last one win would let a tampered manifest shadow the genuine hash with an attacker-chosen one — so the whole manifest is rejected.
var ErrChecksumManifestMalformed = errors.New("checksums manifest is malformed")
ErrChecksumManifestMalformed is returned when the checksums manifest does not conform to the expected GoReleaser format (`<sha256-hex> <filename>` per line). Rather than silently skip malformed lines, the parser rejects the entire manifest so a truncated or corrupted download never produces a false pass.
var ErrChecksumTooLarge = errors.New("download exceeds maximum size")
ErrChecksumTooLarge is returned when either the checksums manifest or the binary download exceeds its configured size bound. Indicates a hostile or misbehaving server; the update aborts before hashing.
Functions ¶
func Chain ¶
func Chain(feature props.FeatureCmd, runE func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error
Chain applies all registered middleware (global + feature-specific) to the given RunE function and returns the wrapped function.
func FeatureOf ¶ added in v0.17.0
func FeatureOf(cmd *cobra.Command) props.FeatureCmd
FeatureOf returns the feature a command was wrapped with via Wrap, or the empty FeatureCmd when the command carries no feature annotation. It works on the raw *cobra.Command, so it is usable from hooks that never see the composing *Command.
func GetCheckedVersion ¶ added in v0.18.0
GetCheckedVersion returns the latest release version recorded by the most recent update check (the body of the last_checked marker), or "" when none has been recorded or the tool was up to date at the last check.
func GetChecks ¶
func GetChecks() map[props.FeatureCmd][]CheckProvider
GetChecks returns a snapshot of all registered check providers.
func GetDefaultConfigDir ¶
GetDefaultConfigDir returns the default config directory for the named tool (~/.toolname/). It returns an empty string when the user home directory cannot be resolved (e.g. HOME is unset or empty) — callers must treat an empty result as "no config dir" and skip any read/write rather than joining it with a filename, which would otherwise resolve to a relative path under the current working directory.
It is pure: it computes and returns the path only and never creates the directory. Building the command tree (--help, completions, default flag values) resolves this path, so a hidden MkdirAll here would create ~/.toolname as a side effect of merely running --help. Directory creation is deferred to the writers that actually persist a file under it (Initialise, setTimeSinceLastIn, the config writers in pkg/cmd), each of which MkdirAlls its parent at write time. The fs parameter is retained for API compatibility and is unused.
func GetFeatureFlags ¶
func GetFeatureFlags() map[props.FeatureCmd][]FeatureFlag
GetFeatureFlags returns a snapshot of all registered feature flag providers.
func GetInitialisers ¶
func GetInitialisers() map[props.FeatureCmd][]InitialiserProvider
GetInitialisers returns a snapshot of all registered initialiser providers.
func GetSubcommands ¶
func GetSubcommands() map[props.FeatureCmd][]SubcommandProvider
GetSubcommands returns a snapshot of all registered subcommand providers.
func GetTimeSinceLast ¶
GetTimeSinceLast returns the duration since the last update check or update, or DefaultCheckInterval when no timestamp has been recorded yet.
func Initialise ¶
func Initialise(props *props.Props, opts InitOptions) (string, error)
Initialise creates the default configuration file in the specified directory.
func IsExposedToMCP ¶ added in v0.21.0
IsExposedToMCP reports whether cmd is exposed on the MCP tool surface. It walks cmd and its ancestors and returns the nearest explicit decision (Exposed→true, Excluded→false), defaulting to true when no command in the chain sets one. This yields subtree exclusion by default while letting a descendant re-expose itself via IncludeInMCP. Operates on the raw *cobra.Command so it is callable from the root MCP selector closure; nil-safe.
func IsSealed ¶ added in v0.17.0
func IsSealed() bool
IsSealed reports whether the middleware registry has been sealed. Callers that register built-in middleware once per process use this to stay idempotent — a second root construction reuses the already-sealed registry instead of re-registering and panicking.
func Register ¶
func Register(feature props.FeatureCmd, ips []InitialiserProvider, sps []SubcommandProvider, fps []FeatureFlag)
Register adds initialisers, subcommands, and flags for a specific feature. Panics if the registry has been sealed.
func RegisterChecks ¶
func RegisterChecks(feature props.FeatureCmd, cps []CheckProvider)
RegisterChecks adds diagnostic check providers for a specific feature. Panics if the registry has been sealed.
func RegisterGlobalMiddleware ¶
func RegisterGlobalMiddleware(mw ...Middleware)
RegisterGlobalMiddleware adds middleware that is applied to all feature commands. Global middleware runs before feature-specific middleware in the chain.
func RegisterMiddleware ¶
func RegisterMiddleware(feature props.FeatureCmd, mw ...Middleware)
RegisterMiddleware adds middleware that will be applied to commands belonging to the specified feature. Middleware is applied in registration order.
func ResetRegistryForTesting ¶
func ResetRegistryForTesting()
ResetRegistryForTesting clears both the middleware and feature registries. This should only be used in tests to avoid state leakage between test runs.
func ResolveCheckInterval ¶ added in v0.18.0
ResolveCheckInterval resolves the update-check throttle from, in order of precedence: the `update.check_interval` config value (if a valid, non-negative Go duration — where "0"/"0s" means "check on every invocation"), then the tool author's baseline (toolDefault, if greater than zero), then DefaultCheckInterval. A toolDefault of zero is treated as "unset" and falls through to the framework default rather than meaning "every run"; runtime config is the only way to request the no-throttle behaviour.
func Seal ¶
func Seal()
Seal prevents further middleware registration. Called after all commands have been registered.
func SealRegistry ¶
func SealRegistry()
SealRegistry prevents further feature registration. Called after all commands have been registered. Subsequent Register* calls will panic.
func SetCheckedVersion ¶ added in v0.18.0
SetCheckedVersion stamps the last-checked marker and stores the latest release version that check discovered as the marker's body, so a later invocation can warn that the running binary is out of date without a network call (see GetCheckedVersion). The marker's modtime still drives the interval throttle — one file, two jobs. A blank version clears the stored value while still refreshing the check timestamp (e.g. when the tool is found up to date).
func SetTimeSinceLast ¶
SetTimeSinceLast records the current time as the last check or update timestamp (an empty marker file whose modtime is the timestamp). When the default config directory cannot be resolved (empty/unset HOME), it is a no-op: stamping a relative path would otherwise write the marker into the current working directory.
func SkipUpdateCheck ¶
func SkipUpdateCheck(fs afero.Fs, name string, cmd *cobra.Command, checkInterval time.Duration) bool
SkipUpdateCheck reports whether the update check should be skipped this invocation: always for the version/update/auth/init commands, and otherwise when a prior check happened within checkInterval. A checkInterval <= 0 means check on every invocation; a missing timestamp (first run) is never skipped, regardless of the interval.
func VerifyChecksum ¶
VerifyChecksum reads a SHA-256 sidecar file and verifies it against the provided data. The sidecar format is "<hex-hash> <filename>" (matching sha256sum output and GoReleaser checksums.txt entries). Returns nil if the checksum matches, or an error with a hint on mismatch.
Hash comparison uses subtle.ConstantTimeCompare on decoded bytes. This is defence-in-depth — practical timing attacks on checksum comparison of unknown binary content are infeasible, but the constant-time primitive eliminates the class of concern at near-zero cost and makes future audits simpler.
func VerifyChecksumFromManifest ¶
VerifyChecksumFromManifest verifies data against a named entry in a GoReleaser-style checksums manifest. The manifest format is one "<hex-sha256> <filename>" entry per line; blank lines are permitted at end-of-file. Every non-blank line must match the expected shape or the manifest is rejected as malformed. A filename listed more than once rejects the whole manifest (ErrChecksumManifestDuplicate) rather than letting the last entry silently win.
Returns nil if the checksum matches, ErrChecksumAssetNotFound if the filename is not listed, ErrChecksumManifestMalformed on invalid syntax, ErrChecksumManifestDuplicate on a repeated filename, or an error wrapping errors.WithHint on mismatch.
func VerifyChecksumFromManifestReader ¶
func VerifyChecksumFromManifestReader( manifest []byte, filename string, dataReader io.Reader, dst io.Writer, maxBytes int64, ) (int64, error)
VerifyChecksumFromManifestReader is the streaming equivalent of VerifyChecksumFromManifest. It computes the SHA-256 of dataReader while copying into dst, avoiding a second pass over multi-megabyte binary data.
maxBytes bounds the total copied; exceeding it returns ErrChecksumTooLarge. A typical caller passes MaxBinaryDownloadSize.
Returns the number of bytes copied on success, or an error on checksum mismatch, size-limit violation, or copy/IO failure. The manifest is parsed before any bytes are hashed, so a manifest- lookup failure aborts without touching dst.
Types ¶
type CheckFunc ¶
type CheckFunc func(ctx context.Context, props *props.Props) CheckResult
CheckFunc is the signature for individual diagnostic checks.
type CheckProvider ¶
CheckProvider is a function that returns diagnostic checks for a feature.
type CheckResult ¶
type CheckResult struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
CheckResult represents the outcome of a single diagnostic check.
type Command ¶ added in v0.5.0
type Command struct {
*cobra.Command
// Feature is the middleware lookup key. The empty string means "no
// feature-specific middleware" (global middleware still applies).
Feature props.FeatureCmd
}
Command composes cobra.Command with the middleware feature key it belongs to. The feature is the lookup key Chain uses to find feature-specific middleware (registered via RegisterMiddleware).
Composing rather than wrapping means callers can use any cobra.Command method directly (the embedded pointer satisfies the interface), and code that needs the raw *cobra.Command — e.g. to pass to a cobra API or store in a parent's Commands() slice — accesses it via .Command.
Commands are typically built via Wrap in each generated NewCmd<Name> constructor and attached to a parent via the parent's Command.Register method, which wires middleware automatically. See the `2026-05-30-command-composition-registration` spec.
func ExcludeFromMCP ¶ added in v0.21.0
ExcludeFromMCP marks cmd as excluded from the MCP tool surface: when the mcp feature is enabled, cmd — and, by inheritance, descendants that do not themselves call IncludeInMCP — is omitted from `mcp tools` / `mcp start`. CLI behaviour is unaffected; the command remains fully runnable. Returns cmd for chaining.
func IncludeInMCP ¶ added in v0.21.0
IncludeInMCP marks cmd as explicitly exposed on the MCP tool surface. Its primary use is to override an excluded ancestor so a specific subcommand stays exposed; it is also stamped for any command whose exposure is explicitly Exposed. Returns cmd for chaining.
func Wrap ¶ added in v0.5.0
func Wrap(feature props.FeatureCmd, cmd *cobra.Command) *Command
Wrap pairs a cobra command with the feature it belongs to. The returned *Command embeds cmd, so it behaves as a cobra.Command for every method cobra offers; .Command exposes the underlying pointer when the cobra API needs *cobra.Command directly.
Wrap also stamps the feature onto the underlying command's Annotations (under FeatureAnnotation) so the feature is recoverable from the raw *cobra.Command via FeatureOf — even where only cobra's own type is in hand.
func (*Command) Register ¶ added in v0.5.0
Register adds each child as a subcommand and wraps the child's RunE with the middleware Chain for the child's own feature.
Each child is wrapped exactly once, at the point its parent registers it. A child's own descendants are wired when the child registers them, so Register never re-wraps a subtree.
Children with a nil RunE (pure command groups) are still attached but receive no RunE-wrapping — there is nothing to wrap.
type FeatureFlag ¶
FeatureFlag is a function that registers flags on a cobra command.
type FeatureRegistry ¶
type FeatureRegistry struct {
// contains filtered or unexported fields
}
FeatureRegistry holds the registered initialisers, subcommands, flags, and checks for features. All access is serialised by registryMu so concurrent init() calls and parallel tests are race-free.
type InitOptions ¶
type InitOptions struct {
Dir string
Clean bool
SkipLogin bool
SkipKey bool
SkipAI bool
Initialisers []Initialiser
// Interactive overrides terminal detection for the credential wizards.
// When nil, interactivity is detected from stdin (utils.IsInteractive).
// Credential initialisers drive interactive prompts that would block on a
// non-terminal stdin, so they are skipped when this resolves to false.
// Tests set it explicitly to avoid depending on the test runner's stdin.
Interactive *bool
}
InitOptions holds the options for the Initialise function.
type Initialiser ¶
type Initialiser interface {
// Name returns a human-readable name for logging.
Name() string
// IsConfigured returns true if this initialiser's config is already present.
IsConfigured(cfg config.Containable) bool
// Configure runs the interactive config and writes values into cfg.
Configure(p *props.Props, cfg config.Containable) error
}
Initialiser is an optional config step that can check if it's already configured and, if not, interactively populate the shared viper config.
type InitialiserProvider ¶
type InitialiserProvider func(p *props.Props) Initialiser
InitialiserProvider is a function that creates an Initialiser.
type MCPExposure ¶ added in v0.21.0
type MCPExposure uint8
MCPExposure is a command's explicit decision about whether it appears on the MCP tool surface. The zero value is MCPExposureInherit, so an unset field or absent annotation naturally means "inherit from the nearest ancestor that sets one". It mirrors the generator manifest's mcp_enabled *bool: nil↔Inherit, true↔Exposed, false↔Excluded.
Exposure is build-time only: the decision is baked into the binary as a command annotation, with no runtime config lever — the MCP tool surface is fixed and auditable in the shipped binary. See docs/development/specs/2026-06-19-mcp-command-exposure-gating.md.
const ( // MCPExposureInherit means the command states no explicit preference and // inherits the nearest ancestor's; the tree default is exposed. MCPExposureInherit MCPExposure = iota // MCPExposureExposed means the command is explicitly on the MCP surface. // Its primary use is overriding an excluded ancestor. MCPExposureExposed // MCPExposureExcluded means the command is explicitly withheld from the // MCP surface. Its descendants inherit this unless they set Exposed. MCPExposureExcluded )
func MCPExposureFromBool ¶ added in v0.21.0
func MCPExposureFromBool(b *bool) MCPExposure
MCPExposureFromBool maps a tri-state *bool (the manifest/CLI representation) to the enum: nil→Inherit, true→Exposed, false→Excluded.
func MCPExposureOf ¶ added in v0.21.0
func MCPExposureOf(cmd *cobra.Command) MCPExposure
MCPExposureOf returns cmd's own explicit exposure decision, or MCPExposureInherit when cmd carries no exposure annotation. It operates on the raw *cobra.Command and is nil-safe.
type Middleware ¶
type Middleware func(next func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error
Middleware wraps a cobra RunE function with additional behaviour. The middleware receives the next handler in the chain and returns a new handler that may execute logic before and/or after calling next.
func WithAuthCheck ¶
func WithAuthCheck(keys ...string) Middleware
WithAuthCheck returns middleware that validates the specified configuration keys are non-empty before allowing command execution. If any key is empty, a descriptive error is returned without executing the command.
func WithRecovery ¶
func WithRecovery(l logger.Logger) Middleware
WithRecovery returns middleware that catches panics in the command handler and converts them to errors. The panic value and stack trace are logged at Error level.
func WithTelemetry ¶
func WithTelemetry(p *props.Props) Middleware
WithTelemetry returns middleware that automatically tracks command invocations via the telemetry collector on Props. Records command name, duration, and exit code for every command execution. No-op when the collector is nil or telemetry is disabled (the collector is a noop in that case).
func WithTiming ¶
func WithTiming(l logger.Logger) Middleware
WithTiming returns middleware that logs command execution duration.
type SelfUpdater ¶
type SelfUpdater struct {
Tool props.Tool
CurrentVersion string
NextRelease release.Release
Fs afero.Fs
// contains filtered or unexported fields
}
SelfUpdater manages checking for and applying tool updates.
func NewOfflineUpdater ¶
func NewOfflineUpdater(tool props.Tool, log logger.Logger, fs afero.Fs, opts ...UpdaterOption) *SelfUpdater
NewOfflineUpdater creates a SelfUpdater configured for file-based updates that do not require a VCS client or network access.
func NewUpdater ¶
func NewUpdater(ctx context.Context, p *props.Props, version string, force bool, opts ...UpdaterOption) (*SelfUpdater, error)
NewUpdater creates a SelfUpdater configured with the tools release source. The context is forwarded to vcs.ResolveTokenContext for private-repository token resolution, so remote-store credential backends (Vault, SSM) honour the caller's deadline when fetching the release token.
func (*SelfUpdater) DownloadAsset ¶
func (s *SelfUpdater) DownloadAsset(ctx context.Context, asset release.ReleaseAsset) (bytes.Buffer, error)
DownloadAsset downloads the raw bytes of a release asset.
func (*SelfUpdater) GetCurrentVersion ¶
func (s *SelfUpdater) GetCurrentVersion() string
func (*SelfUpdater) GetLatestRelease ¶
func (*SelfUpdater) GetLatestVersionString ¶
func (s *SelfUpdater) GetLatestVersionString(ctx context.Context) (string, error)
func (*SelfUpdater) GetReleaseNotes ¶
GetReleaseNotes retrieves the release notes for releases between the specified 'from' and 'to' versions (inclusive).
func (*SelfUpdater) GetStructuredReleaseNotes ¶
func (s *SelfUpdater) GetStructuredReleaseNotes(ctx context.Context, from, to string, archive ...bytes.Buffer) (*changelog.Changelog, error)
GetStructuredReleaseNotes retrieves release notes between two versions and returns them as a parsed Changelog. If an archive buffer is provided, it attempts to extract a bundled CHANGELOG.md first, falling back to per-release API calls when the archive contains no changelog.
func (*SelfUpdater) IsLatestVersion ¶
IsLatestVersion checks if the current running binary is the latest version.
func (*SelfUpdater) SignatureAssetName ¶ added in v0.12.0
func (s *SelfUpdater) SignatureAssetName() string
SignatureAssetName returns the configured signature filename, or the GoReleaser default "checksums.txt.sig" when unset.
func (*SelfUpdater) Update ¶
func (s *SelfUpdater) Update(ctx context.Context) (string, error)
Update installs the latest version of the binary to the resolved target path.
func (*SelfUpdater) UpdateFromFile ¶
func (s *SelfUpdater) UpdateFromFile(filePath string) (string, error)
UpdateFromFile installs a binary from a local .tar.gz file. If a .sha256 sidecar file exists at filePath+".sha256", the checksum is verified before extraction. Returns the installation target path.
type SubcommandProvider ¶
SubcommandProvider is a function that creates a slice of cobra subcommands.
type UpdaterOption ¶
type UpdaterOption func(*SelfUpdater)
UpdaterOption configures a SelfUpdater.
func WithEmbeddedKeys ¶ added in v0.12.0
func WithEmbeddedKeys(armoredKeys ...[]byte) UpdaterOption
WithEmbeddedKeys supplies the tool's embedded release public keys (in ASCII-armored form). NewUpdater builds the default resolver from these keys and the resolved update.key_source / external_key_email / require_external_crosscheck config. Ignored when WithKeyResolver is also supplied.
func WithExecLookPath ¶
func WithExecLookPath(fn func(string) (string, error)) UpdaterOption
WithExecLookPath overrides exec.LookPath for testing.
func WithKeyResolver ¶ added in v0.12.0
func WithKeyResolver(r verify.KeyResolver) UpdaterOption
WithKeyResolver overrides the default key resolver used for signature verification. When set, the config-driven default (built from WithEmbeddedKeys and the update.key_source family) is bypassed entirely — the tool author owns the resolver chain.
func WithOsExecutable ¶
func WithOsExecutable(fn func() (string, error)) UpdaterOption
WithOsExecutable overrides os.Executable for testing.
func WithReleaseProvider ¶ added in v0.21.0
func WithReleaseProvider(p release.Provider) UpdaterOption
WithReleaseProvider injects the release.Provider the SelfUpdater uses, bypassing the ReleaseSource.Type registry lookup (and, with it, the private-repository token gate that precedes the lookup — an injected provider is self-contained and owns its own auth). Parallel-safe: each call site receives its own provider, with no global registry mutation. Takes precedence over a props.Tool.ReleaseProvider field.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ai provides the interactive AI-provider setup initialiser.
|
Package ai provides the interactive AI-provider setup initialiser. |
|
Package bitbucket implements the interactive setup wizard for Bitbucket Cloud authentication.
|
Package bitbucket implements the interactive setup wizard for Bitbucket Cloud authentication. |
|
Package github provides the interactive GitHub setup initialiser.
|
Package github provides the interactive GitHub setup initialiser. |
|
Package telemetry registers the telemetry initialiser with the setup system.
|
Package telemetry registers the telemetry initialiser with the setup system. |