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 ¶
- func TemplateError(err error, name string) error
- type Tool
- func (t Tool) AbsPath() string
- func (t *Tool) CheckSkipConditions(tags tags.IncludeTags) result.Result
- func (t Tool) Copy() (Tool, error)
- func (t *Tool) DisableCache()
- func (t *Tool) Download(progressListener getter.ProgressTracker) result.Result
- func (t *Tool) EnableCache(cache *cache.Cache)
- func (t Tool) Exists() bool
- func (t Tool) GetCurrentVersion() string
- func (t Tool) GetStrategy() strategy.Strategy
- func (t Tool) GetTargetVersion() string
- func (t Tool) ID() string
- func (t *Tool) Resolve(tags tags.IncludeTags, dry bool) result.Result
- func (t *Tool) Result() *result.Result
- func (t *Tool) SetResult(res result.Result)
- func (t *Tool) TemplateFirst() error
- func (t *Tool) TemplateLast() error
- func (t *Tool) ToTemplateMap(flatten ...map[string]any) map[string]any
- func (t *Tool) UnmarshalYAML(value *yaml.Node) error
- func (t *Tool) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TemplateError ¶
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) 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) 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 ¶
EnableCache sets the cache for the Tool instance.
func (Tool) Exists ¶
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 ¶
GetCurrentVersion attempts to retrieve the current version of the tool.
func (Tool) GetStrategy ¶
GetStrategy returns the tool's strategy.
func (Tool) GetTargetVersion ¶
GetTargetVersion returns the tool's target version.
func (*Tool) Resolve ¶
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) TemplateFirst ¶
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 ¶
TemplateLast applies templating to the remaining fields of the Tool struct.
func (*Tool) ToTemplateMap ¶
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 ¶
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.