tools

package
v0.34.2 Latest Latest
Warning

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

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

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

View Source
const (
	PreferVendored = "vendored"
	PreferSystem   = "system"
)

PreferVendored and PreferSystem are the valid values for Options.Prefer.

Variables

View Source
var All = []Tool{Kubectl, Helm, K3d}

All lists every managed tool, in a stable order.

Functions

func PinnedVersion

func PinnedVersion(t Tool) string

PinnedVersion returns the version devrig fetches and validates for a tool.

func SupportedPlatform

func SupportedPlatform(t Tool) bool

SupportedPlatform reports whether the current GOOS/GOARCH has a pinned artifact for t.

Types

type NotFoundError

type NotFoundError struct {
	Tool Tool
	Dir  string
}

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

func NewResolver(o Options) *Resolver

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) Command

func (r *Resolver) Command(ctx context.Context, t Tool, args ...string) (*exec.Cmd, error)

Command builds an *exec.Cmd for a tool, resolving its path first.

func (*Resolver) Install

func (r *Resolver) Install(ctx context.Context, t Tool, force bool) (string, error)

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

func (r *Resolver) ManagedPath(t Tool) string

ManagedPath returns the absolute path where the pinned managed copy of t lives (whether or not it currently exists).

func (*Resolver) Path

func (r *Resolver) Path(ctx context.Context, t Tool) (string, error)

Path resolves a tool to an absolute executable path, fetching a managed copy if necessary and permitted. Precedence depends on Options.Prefer; see the package doc and PRD.

func (*Resolver) Status

func (r *Resolver) Status(t Tool) Status

Status reports resolution state for a tool without fetching anything.

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

type Tool

type Tool string

Tool identifies a managed external dependency.

const (
	Kubectl Tool = "kubectl"
	Helm    Tool = "helm"
	K3d     Tool = "k3d"
)

Jump to

Keyboard shortcuts

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