Documentation
¶
Overview ¶
Package tools manages the external CLIs devrig's cluster features depend on (k3d, kubectl, helm). It can resolve them from the user's PATH or fetch pinned, checksum-verified copies into a devrig-private directory (~/.devrig/bin) so the cluster workflow works on a machine that has none of them installed — without shadowing the user's own copies on PATH.
See docs/prd/managed-tool-deps.md for the design.
Index ¶
- Constants
- Variables
- func PinnedVersion(t Tool) string
- func SupportedPlatform(t Tool) bool
- func VerboseFlags(t Tool) []string
- type NotFoundError
- type Options
- type Resolver
- func (r *Resolver) Command(ctx context.Context, t Tool, args ...string) (*exec.Cmd, error)
- func (r *Resolver) Install(ctx context.Context, t Tool, force bool) (string, error)
- func (r *Resolver) ManagedPath(t Tool) string
- func (r *Resolver) Path(ctx context.Context, t Tool) (string, error)
- func (r *Resolver) Status(t Tool) Status
- type Status
- type Tool
Constants ¶
const ( PreferVendored = "vendored" PreferSystem = "system" )
PreferVendored and PreferSystem are the valid values for Options.Prefer.
Variables ¶
var All = []Tool{Kubectl, Helm, K3d}
All lists every managed tool, in a stable order.
Functions ¶
func PinnedVersion ¶
PinnedVersion returns the version devrig fetches and validates for a tool.
func SupportedPlatform ¶
SupportedPlatform reports whether the current GOOS/GOARCH has a pinned artifact for t.
func VerboseFlags ¶ added in v0.38.0
VerboseFlags returns the tool's own verbosity flags when devrig's verbose mode is on, so the underlying CLI also logs at a higher level. It returns nil otherwise. The flags are global/persistent for each tool, so they are safe to append to any subcommand invocation.
Types ¶
type NotFoundError ¶
NotFoundError is returned when a tool cannot be resolved or fetched.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Options ¶
type Options struct {
// Prefer chooses managed ("vendored", the default) or "system" binaries
// when both are available.
Prefer string
// Overrides maps a tool to an explicit executable path that wins over both
// managed and system resolution.
Overrides map[Tool]string
// Dir is the managed-binary directory. Defaults to ~/.devrig/bin.
Dir string
// AllowFetch permits downloading a missing managed tool. Callers typically
// set this from a TTY check; `devrig deps install` forces it true.
AllowFetch bool
// Stderr receives human-facing progress ("Fetching managed kubectl ...").
// Defaults to os.Stderr.
Stderr io.Writer
}
Options configures a Resolver.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves tools to absolute executable paths per its Options.
func NewResolver ¶
NewResolver returns a Resolver, filling in defaults for unset Options.
func ResolverFromConfig ¶
func ResolverFromConfig(c *config.ToolsConfig, allowFetch bool) *Resolver
ResolverFromConfig builds a Resolver from the devrig tools config block. A nil block yields defaults (prefer vendored, no overrides). allowFetch controls whether missing managed tools are downloaded on demand.
func (*Resolver) Install ¶
Install fetches a tool's managed copy unconditionally (used by `devrig deps install`). If force is false and the pinned copy already exists, it is a no-op.
func (*Resolver) ManagedPath ¶
ManagedPath returns the absolute path where the pinned managed copy of t lives (whether or not it currently exists).
type Status ¶
type Status struct {
Tool Tool
Pinned string
ManagedPath string // path if a managed pinned copy exists, else ""
SystemPath string // path if found on PATH, else ""
OverridePath string // explicit override, else ""
WillUse string // the path Path() would return without fetching, else ""
}
Status describes how a tool currently resolves, for `devrig deps`/`doctor`.