toolinstall

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinDir

func BinDir() string

BinDir returns the directory where tool binaries/symlinks are placed. This is ToolsDir()/bin/

func EnsureCommand

func EnsureCommand(ctx context.Context, command, version string) (string, error)

EnsureCommand makes sure a command binary is available. It checks PATH first, then the docker agent tools directory, then attempts to install from the aqua registry if auto-install is enabled.

Returns the resolved command (may be the same string if found in PATH, or a full path to the installed binary) and any error encountered. When auto-install is disabled (globally or per-toolset), the original command is returned with no error.

func PackageDir

func PackageDir(owner, repo, version string) string

PackageDir returns the directory for a specific package version. This is ToolsDir()/packages/<owner>/<repo>/<version>/

func PrependBinDirToEnv

func PrependBinDirToEnv(env []string) []string

PrependBinDirToEnv takes an env slice and ensures the tools bin directory is prepended to the PATH entry. This allows installed tools to find other installed tools (e.g., npx finding node).

func RegistryDir

func RegistryDir() string

RegistryDir returns the directory for cached registry data.

func ToolsDir

func ToolsDir() string

ToolsDir returns the base directory for installed tools. Checks DOCKER_AGENT_TOOLS_DIR env var, defaults to ~/.cagent/tools/

Types

type Override

type Override struct {
	GOOS         string            `yaml:"goos"`
	GOArch       string            `yaml:"goarch"`
	Asset        string            `yaml:"asset"`
	Format       string            `yaml:"format"`
	Files        []PackageFile     `yaml:"files"`
	Replacements map[string]string `yaml:"replacements"`
}

Override represents a platform-specific override for a package.

type Package

type Package struct {
	Type          string            `yaml:"type"`
	RepoOwner     string            `yaml:"repo_owner"`
	RepoName      string            `yaml:"repo_name"`
	Description   string            `yaml:"description"`
	Asset         string            `yaml:"asset"`
	Format        string            `yaml:"format"`
	Files         []PackageFile     `yaml:"files"`
	Overrides     []Override        `yaml:"overrides"`
	Replacements  map[string]string `yaml:"replacements"`
	SupportedEnvs []string          `yaml:"supported_envs"`
	VersionFilter string            `yaml:"version_filter"`
	VersionPrefix string            `yaml:"version_prefix"`
	Name          string            `yaml:"name"`

	// GoInstallPath is the Go module path for go_install/go_build packages.
	// Example: "golang.org/x/tools/gopls"
	GoInstallPath string `yaml:"path"`
}

Package represents a parsed aqua registry package definition.

func (*Package) BinaryName

func (p *Package) BinaryName() string

BinaryName returns the primary binary name this package provides.

func (*Package) IsGoPackage

func (p *Package) IsGoPackage() bool

IsGoPackage returns true if this package is installed via "go install".

type PackageFile

type PackageFile struct {
	Name string `yaml:"name"`
	Src  string `yaml:"src"`
}

PackageFile describes a file within a downloaded archive.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry provides lookup of aqua packages.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry with default settings.

func SharedRegistry

func SharedRegistry() *Registry

SharedRegistry returns a package-level Registry instance that is reused across all tool resolutions within a docker agent session, avoiding repeated YAML parsing and HTTP fetches.

func (*Registry) Install

func (r *Registry) Install(ctx context.Context, pkg *Package, version string) (string, error)

Install downloads and installs a package at the specified version. Returns the path to the installed binary.

func (*Registry) LookupByCommand

func (r *Registry) LookupByCommand(ctx context.Context, command string) (*Package, error)

LookupByCommand searches for a package providing a binary matching the command name. First checks repo names, then files[].name across all packages.

func (*Registry) LookupByName

func (r *Registry) LookupByName(ctx context.Context, name string) (*Package, error)

LookupByName searches the registry for a package by "owner/repo" identifier. Searches the full registry index first, then falls back to fetching the per-package YAML from pkgs/<owner>/<repo>/registry.yaml.

Jump to

Keyboard shortcuts

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