tool

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package tool provides core functionality for managing tool configurations.

Package tool provides core functionality for managing tool configurations.

Package tool provides core functionality for managing tool configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateError

func TemplateError(err error, name string) error

TemplateError wraps an error with additional context about the template name.

Types

type Tool

type Tool struct {
	// Name of the tool, usually a short identifier or title.
	Name string `validate:"required"`
	// Description of the tool, giving more context about its purpose.
	Description string
	// Version specifies the version of the tool.
	Version version.Version
	// Path represents the URL where the tool can be downloaded from.
	URL string
	// Output defines the output path where the tool will be installed or extracted.
	Output string
	// Exe specifies the executable details for the tool, such as patterns or names for locating the binary.
	Exe exe.Exe
	// Platform defines the platform-specific details for the tool, including OS and architecture constraints.
	Platform detect.Platform
	// Aliases represent alternative names or shortcuts for the tool.
	Aliases aliases.Aliases
	// Values contains custom values or variables used in the tool's configuration.
	Values values.Values
	// Fallbacks defines fallback configurations in case the primary configuration fails.
	Fallbacks fallbacks.Fallbacks
	// Hints provide additional matching patterns or heuristics for the tool.
	Hints match.Hints
	// Source defines the source configuration, which determines how the tool is fetched (e.g., GitHub, local files).
	Source sources.Source
	// Commands contains a set of commands that can be executed in the context of the tool.
	Commands command.Commands
	// Tags are labels or markers that can be used to categorize or filter the tool.
	Tags tags.Tags
	// Strategy defines how the tool is deployed, fetched, or managed (e.g., download strategies, handling retries).
	Strategy strategy.Strategy
	// Extensions lists additional files or behaviors that are tied to the tool.
	Extensions extensions.Extensions
	// Skip defines conditions under which certain steps (e.g., downloading, testing) are skipped.
	Skip skip.Skip
	// Mode defines the operating mode for the tool, potentially controlling behavior such as silent mode or verbose mode.
	Mode mode.Mode
	// Env defines the environment variables that are applied when running the tool.
	Env env.Env
	// NoVerifySSL specifies whether SSL verification should be disabled when fetching the tool.
	NoVerifySSL bool `yaml:"no_verify_ssl"`
	// NoCache disables cache interaction
	NoCache bool `mapstructure:"no_cache"`
	// Inherit is used to determine which default configurations the tool should inherit from.
	Inherit inherit.Inherit
	// contains filtered or unexported fields
}

Tool represents a single tool configuration. It contains various fields that specify details such as the tool's name, version, path, execution settings, platform-specific settings, environment variables, and custom strategies for downloading, testing, or deploying.

func (Tool) AbsPath

func (t Tool) AbsPath() string

AbsPath returns the absolute path of the tool's executable.

func (*Tool) CheckSkipConditions

func (t *Tool) CheckSkipConditions(tags tags.IncludeTags) result.Result

CheckSkipConditions determines if a tool should be skipped based on its tags, strategy, and skip conditions. Returns a Result with the skip status and reason.

func (Tool) Copy

func (t Tool) Copy() (Tool, error)

Copy creates a deep copy of the Tool instance.

func (*Tool) DisableCache

func (t *Tool) DisableCache()

EnableCache sets the cache for the Tool instance.

func (*Tool) Download

func (t *Tool) Download(progressListener getter.ProgressTracker) result.Result

Download retrieves and installs the tool using its configured source and installer. It handles progress tracking and executes any post-installation commands. Returns a Result indicating success or failure with detailed messages.

func (*Tool) EnableCache

func (t *Tool) EnableCache(cache *cache.Cache)

EnableCache sets the cache for the Tool instance.

func (Tool) Exists

func (t Tool) Exists() bool

Exists checks if the tool's executable exists in the configured output path. Returns true if the file exists and is a regular file.

func (Tool) GetCurrentVersion

func (t Tool) GetCurrentVersion() string

GetCurrentVersion attempts to retrieve the current version of the tool.

func (Tool) GetStrategy

func (t Tool) GetStrategy() strategy.Strategy

GetStrategy returns the tool's strategy.

func (Tool) GetTargetVersion

func (t Tool) GetTargetVersion() string

GetTargetVersion returns the tool's target version.

func (Tool) ID

func (t Tool) ID() string

ID generates a unique identifier for the tool based on its output path and name.

func (*Tool) Resolve

func (t *Tool) Resolve(tags tags.IncludeTags, dry bool) result.Result

Resolve attempts to resolve the tool's source and strategy based on the provided tags. It handles environment variables, fallbacks, templating, and validation of the tool's configuration. Returns a Result indicating success or failure with detailed messages.

func (*Tool) Result

func (t *Tool) Result() *result.Result

Result returns the current result of the Tool instance.

func (*Tool) SetResult

func (t *Tool) SetResult(res result.Result)

SetResult sets the current result of the Tool instance.

func (*Tool) TemplateFirst

func (t *Tool) TemplateFirst() error

TemplateFirst applies templating to various fields of the Tool struct, such as version, path, and checksum. It processes these fields using Go templates and updates them with the templated values.

func (*Tool) TemplateLast

func (t *Tool) TemplateLast() error

TemplateLast applies templating to the remaining fields of the Tool struct.

func (*Tool) ToTemplateMap

func (t *Tool) ToTemplateMap(flatten ...map[string]any) map[string]any

ToTemplateMap converts the Tool struct to a map suitable for templating. It adds any additional maps provided in the flatten argument to the template map.

func (*Tool) UnmarshalYAML

func (t *Tool) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom YAML unmarshaling for Tool configuration. Supports both scalar values (treated as tool name) and map values with field validation. Ensures only known fields are present in the YAML configuration.

func (*Tool) Validate

func (t *Tool) Validate() error

Validate performs structural validation of the Tool's configuration using the validator package. Returns an error if validation fails.

Jump to

Keyboard shortcuts

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