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.
Package tool provides core functionality for managing tool configurations.
Index ¶
- func TemplateError(err error, name string) error
- type ResolveOption
- type Tool
- func (t Tool) AbsPath() string
- func (t *Tool) CheckSkipConditions(tags tags.IncludeTags) result.Result
- func (t *Tool) Copied() (*Tool, error)
- func (t *Tool) CopiedYAML() (*Tool, error)
- func (t *Tool) Copy() error
- func (t *Tool) CopyYAML() error
- func (t Tool) Debug(tool, s string)
- func (t *Tool) DisableCache()
- func (t *Tool) Download(_ context.Context, 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) GetPopulator() sources.Populator
- func (t Tool) GetStrategy() strategy.Strategy
- func (t Tool) GetTargetVersion() string
- func (t Tool) ID() string
- func (t *Tool) Marshal() ([]byte, error)
- func (t *Tool) MergeFrom(others ...*Tool) error
- func (t *Tool) MergeInto(others ...*Tool) error
- func (t *Tool) MergePlatform(platform detect.Platform)
- func (t *Tool) MergeWithOther(other *Tool) error
- func (t *Tool) Resolve(tags tags.IncludeTags, options ...ResolveOption) result.Result
- func (t *Tool) Result() *result.Result
- func (t *Tool) SetResult(res result.Result)
- func (t *Tool) TemplateFirst(tmpl *templates.Processor) error
- func (t *Tool) TemplateLast(tmpl *templates.Processor) error
- func (t *Tool) ToTemplateMap(_ ...map[string]any) map[string]any
- func (t *Tool) UnmarshalFrom(other *Tool) error
- func (t *Tool) UnmarshalInto(other *Tool) error
- func (t *Tool) UnmarshalYAML(node ast.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 ResolveOption ¶ added in v0.0.13
type ResolveOption func(*resolveOptions)
ResolveOption is a functional option type for the Resolve method.
func WithUpUntilVersion ¶ added in v0.0.13
func WithUpUntilVersion() ResolveOption
WithUpUntilVersion returns a ResolveOption that enables version checking up to a specific version. This option enables version comparison during tool resolution.
func WithoutURL ¶ added in v0.0.13
func WithoutURL() ResolveOption
WithoutURL returns a ResolveOption that skips URL resolution. This option disables URL-related processing during tool resolution.
func WithoutVersion ¶ added in v0.0.13
func WithoutVersion() ResolveOption
WithoutVersion returns a ResolveOption that skips version resolution. This option disables version-related processing during tool resolution.
type Tool ¶
type Tool struct {
// Name of the tool, usually a short identifier or title.
Name string `json:"name" mapstructure:"name" single:"true" validate:"required" yaml:"name"`
// Description of the tool, giving more context about its purpose.
Description string `json:"description" mapstructure:"description" yaml:"description"`
// Version specifies the version of the tool.
Version version.Version `json:"version" mapstructure:"version" yaml:"version"`
// Path represents the URL where the tool can be downloaded from.
URL string `json:"url" mapstructure:"url" yaml:"url"`
// Output defines the output path where the tool will be installed or extracted.
Output string `json:"output" mapstructure:"output" yaml:"output"`
// Exe specifies the executable details for the tool, such as patterns or names for locating the binary.
Exe exe.Exe `json:"exe" mapstructure:"exe" yaml:"exe"`
// Platform defines the platform-specific details for the tool, including OS and architecture constraints.
Platform detect.Platform `json:"platform" mapstructure:"platform" yaml:"platform"`
// Aliases represent alternative names or shortcuts for the tool.
Aliases aliases.Aliases `json:"aliases" mapstructure:"aliases" yaml:"aliases"`
// Values contains custom values or variables used in the tool's configuration.
Values values.Values `json:"values" mapstructure:"values" yaml:"values"`
// Fallbacks defines fallback configurations in case the primary configuration fails.
Fallbacks fallbacks.Fallbacks `json:"fallbacks" mapstructure:"fallbacks" yaml:"fallbacks"`
// Hints provide additional matching patterns or heuristics for the tool.
Hints *hints.Hints `json:"hints" mapstructure:"hints" yaml:"hints"`
// Source defines the source configuration, which determines how the tool is fetched (e.g., GitHub, local files).
Source sources.Source `json:"source" mapstructure:"source" yaml:"source"`
// Commands contains a set of commands that can be executed in the context of the tool.
Commands command.Commands `json:"commands" mapstructure:"commands" yaml:"commands"`
// Tags are labels or markers that can be used to categorize or filter the tool.
Tags tags.Tags `json:"tags" mapstructure:"tags" yaml:"tags"`
// Strategy defines how the tool is deployed, fetched, or managed (e.g., download strategies, handling retries).
Strategy strategy.Strategy `json:"strategy" mapstructure:"strategy" yaml:"strategy"`
// Skip defines conditions under which certain steps (e.g., downloading, testing) are skipped.
Skip skip.Skip `json:"skip" mapstructure:"skip" yaml:"skip"`
Mode mode.Mode `json:"mode" mapstructure:"mode" yaml:"mode"`
// Env defines the environment variables that are applied when running the tool.
Env env.Env `json:"env" mapstructure:"env" yaml:"env"`
// NoVerifySSL specifies whether SSL verification should be disabled when fetching the tool.
NoVerifySSL bool `json:"no-verify-ssl" mapstructure:"no-verify-ssl" yaml:"no-verify-ssl"`
// NoCache disables cache interaction
NoCache bool `json:"no-cache" mapstructure:"no-cache" yaml:"no-cache"`
// Inherit is used to determine which default configurations the tool should inherit from.
Inherit *inherit.Inherit `json:"inherit" mapstructure:"inherit" yaml:"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 MergeLeftToRight ¶ added in v0.0.13
MergeLeftToRight merges the provided tools into a new tool, left to right.
func MergeRightToLeft ¶ added in v0.0.13
MergeRightToLeft merges the provided tools into a new tool, right to left.
func NewEmptyTool ¶ added in v0.0.13
func NewEmptyTool() *Tool
NewEmptyTool returns an empty tool to make sure that no pointers are nil.
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) CopiedYAML ¶ added in v0.0.13
CopiedYAML creates a new Tool instance by marshaling to YAML and unmarshaling. Returns a new Tool instance created through YAML serialization.
func (*Tool) CopyYAML ¶ added in v0.0.13
CopyYAML performs a YAML-based copy operation on the tool. It marshals the tool to YAML and then unmarshals it back.
func (Tool) Debug ¶ added in v0.0.13
Debug prints debug information for the tool if the tool name matches the specified tool.
func (*Tool) DisableCache ¶
func (t *Tool) DisableCache()
DisableCache removes the cache from the Tool instance.
func (*Tool) Download ¶
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) GetPopulator ¶ added in v0.0.13
GetPopulator returns the last successful populator used by the tool.
func (Tool) GetStrategy ¶
GetStrategy returns the tool's strategy.
func (Tool) GetTargetVersion ¶
GetTargetVersion returns the tool's target version.
func (*Tool) MergeFrom ¶ added in v0.0.13
MergeFrom merges the current tool with the provided tools, the sequence being.
tool <-- others[0] <-- others[1] <-- others[2]...
func (*Tool) MergeInto ¶ added in v0.0.13
MergeInto the current tool into the provided tools, the sequence being.
others[0] <-- others[1] <-- others[2]... <-- tool
func (*Tool) MergePlatform ¶ added in v0.0.13
MergePlatform merges the provided platform into the tool. Only empty fields are set.
func (*Tool) MergeWithOther ¶ added in v0.0.13
MergeWithOther behaves like MergeInto, with special handling for slices that need to be appended instead of replaced.
func (*Tool) Resolve ¶
func (t *Tool) Resolve(tags tags.IncludeTags, options ...ResolveOption) 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) SetResult ¶
SetResult sets the current result of the Tool instance.
TODO(Idelchi): Get rid of currentResult. //nolint:godox // TODO comment provides valuable context for future development.
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. Templates:
- Exe.Patterns
- Commands
- Hints patterns and weights
- URL
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) UnmarshalFrom ¶ added in v0.0.13
UnmarshalFrom unmarshals the tool from another tool.
func (*Tool) UnmarshalInto ¶ added in v0.0.13
UnmarshalInto unmarshals the tool into another tool.
func (*Tool) UnmarshalYAML ¶
UnmarshalYAML implements custom YAML unmarshaling for Tool configuration. Supports both scalar values (treated as tool name) and map values.