Documentation ¶
Index ¶
- Variables
- func EncodeYaml(w io.Writer, v any) (errOut error)
- func GetJSONSchema() (*jsonschema.Schema, error)
- func SortBySemverOrString(vals []string)
- func Unique[V comparable](vals, buf []V) []V
- type AddDependencyFromTemplateOpts
- type Config
- func (c *Config) AddChecksums(dependencies []string, systems []System) error
- func (c *Config) AddDependencyFromTemplate(ctx context.Context, templateName string, opts *AddDependencyFromTemplateOpts) (*Dependency, map[string][]string, error)
- func (c *Config) BinName(depName string, system System) (string, error)
- func (c *Config) BuildDependency(depName string, system System) (*Dependency, error)
- func (c *Config) ClearCache() error
- func (c *Config) CopyTemplateFromSource(ctx context.Context, src, srcTemplate, destName string) error
- func (c *Config) DependencySystems(depName string) ([]System, error)
- func (c *Config) DownloadDependency(name string, system System, opts *ConfigDownloadDependencyOpts) (_ string, errOut error)
- func (c *Config) ExtractDependency(dependencyName string, system System, opts *ConfigExtractDependencyOpts) (_ string, errOut error)
- func (c *Config) InstallDependency(dependencyName string, system System, opts *ConfigInstallDependencyOpts) (_ string, errOut error)
- func (c *Config) ListTemplates(ctx context.Context, templateSource string) ([]string, error)
- func (c *Config) MissingDependencyVars(depName string) ([]string, error)
- func (c *Config) PruneChecksums() error
- func (c *Config) SetDependencyVars(depName string, vars map[string]string) error
- func (c *Config) SetTemplateVars(tmplName string, vars map[string]string) error
- func (c *Config) UnsetDependencyVars(depName string, vars []string) error
- func (c *Config) UnsetTemplateVars(tmplName string, vars []string) error
- func (c *Config) Validate(depName string, systems []System) (errOut error)
- func (c *Config) WriteFile(outputJSON bool) (errOut error)
- type ConfigDownloadDependencyOpts
- type ConfigExtractDependencyOpts
- type ConfigInstallDependencyOpts
- type Dependency
- type DependencyOverride
- type Overrideable
- type System
Constants ¶
This section is empty.
Variables ¶
CurrentSystem is the system that bindown is running on
var GoDists string
Functions ¶
func GetJSONSchema ¶ added in v4.4.0
func GetJSONSchema() (*jsonschema.Schema, error)
func SortBySemverOrString ¶ added in v4.3.0
func SortBySemverOrString(vals []string)
func Unique ¶ added in v4.3.0
func Unique[V comparable](vals, buf []V) []V
Unique appends unique values from vals to buf and returns buf
Types ¶
type AddDependencyFromTemplateOpts ¶
type AddDependencyFromTemplateOpts struct { TemplateSource string DependencyName string Vars map[string]string }
AddDependencyFromTemplateOpts options for AddDependencyFromTemplate
type Config ¶
type Config struct { // The directory where bindown will cache downloads and extracted files. This is relative to the directory where // the configuration file resides. cache paths should always use / as a delimiter even on Windows or other // operating systems where the native delimiter isn't /. Cache string `json:"cache,omitempty" yaml:"cache,omitempty"` // The directory that bindown installs files to. This is relative to the directory where the configuration file // resides. install_directory paths should always use / as a delimiter even on Windows or other operating systems // where the native delimiter isn't /. InstallDir string `json:"install_dir,omitempty" yaml:"install_dir,omitempty"` // List of systems supported by this config. Systems are in the form of os/architecture. Systems []System `json:"systems,omitempty" yaml:"systems,omitempty"` // Dependencies available for bindown to install. Dependencies map[string]*Dependency `json:"dependencies,omitempty" yaml:",omitempty"` // Templates that can be used by dependencies in this file. Templates map[string]*Dependency `json:"templates,omitempty" yaml:",omitempty"` // Upstream sources for templates. TemplateSources map[string]string `json:"template_sources,omitempty" yaml:"template_sources,omitempty"` // Checksums of downloaded files. URLChecksums map[string]string `json:"url_checksums,omitempty" yaml:"url_checksums,omitempty"` Filename string `json:"-" yaml:"-"` }
func ConfigFromYAML ¶
func (*Config) AddChecksums ¶
AddChecksums downloads, calculates checksums and adds them to the config's URLChecksums. AddChecksums skips urls that already exist in URLChecksums.
func (*Config) AddDependencyFromTemplate ¶
func (c *Config) AddDependencyFromTemplate(ctx context.Context, templateName string, opts *AddDependencyFromTemplateOpts) (*Dependency, map[string][]string, error)
AddDependencyFromTemplate adds a dependency to the config. Returns a map of known values for template vars
func (*Config) BuildDependency ¶
func (c *Config) BuildDependency(depName string, system System) (*Dependency, error)
BuildDependency returns a dependency with templates and overrides applied and variables interpolated for the given system.
func (*Config) ClearCache ¶
func (*Config) CopyTemplateFromSource ¶
func (c *Config) CopyTemplateFromSource(ctx context.Context, src, srcTemplate, destName string) error
CopyTemplateFromSource copies a template from source
func (*Config) DependencySystems ¶
DependencySystems returns the supported systems of either the config or the dependency if one is not empty if both are not empty, it returns the intersection of the lists
func (*Config) DownloadDependency ¶
func (c *Config) DownloadDependency( name string, system System, opts *ConfigDownloadDependencyOpts, ) (_ string, errOut error)
DownloadDependency downloads a dependency
func (*Config) ExtractDependency ¶
func (c *Config) ExtractDependency(dependencyName string, system System, opts *ConfigExtractDependencyOpts) (_ string, errOut error)
ExtractDependency downloads and extracts a dependency
func (*Config) InstallDependency ¶
func (c *Config) InstallDependency(dependencyName string, system System, opts *ConfigInstallDependencyOpts) (_ string, errOut error)
InstallDependency downloads, extracts and installs a dependency
func (*Config) ListTemplates ¶
ListTemplates lists templates available in this config or one of its template sources.
func (*Config) MissingDependencyVars ¶
MissingDependencyVars returns a list of vars that are required but undefined
func (*Config) PruneChecksums ¶
PruneChecksums removes checksums for dependencies that are not used by any configured system.
func (*Config) SetDependencyVars ¶
SetDependencyVars sets the value of a dependency's var. Adds or Updates the var.
func (*Config) SetTemplateVars ¶
SetTemplateVars sets the value of a template's var. Adds or Updates the var.
func (*Config) UnsetDependencyVars ¶
UnsetDependencyVars removes a dependency var. Noop if the var doesn't exist.
func (*Config) UnsetTemplateVars ¶
UnsetTemplateVars removes a template var. Noop if the var doesn't exist.
type ConfigDownloadDependencyOpts ¶
ConfigDownloadDependencyOpts options for Config.DownloadDependency
type ConfigExtractDependencyOpts ¶
ConfigExtractDependencyOpts options for Config.ExtractDependency
type ConfigInstallDependencyOpts ¶
type ConfigInstallDependencyOpts struct { // TargetPath is the path where the executable should end up TargetPath string // Force - install even if it already exists Force bool // AllowMissingChecksum - whether to allow missing checksum AllowMissingChecksum bool }
ConfigInstallDependencyOpts provides options for Config.InstallDependency
type Dependency ¶
type Dependency struct { // The homepage for this dependency. Informational only. Homepage *string `json:"homepage,omitempty" yaml:",omitempty"` // A description of the dependency. Informational only. Description *string `json:"description,omitempty" yaml:",omitempty"` // A template for this dependency. Value is the name of a template in the templates section of this config. // Any unset fields in this dependency will be set by values from the template. Overrides in the dependency // and its template are concatenated with the template's overrides coming first. Vars and substitutions // are both combined with the dependency's value taking precedence. Template *string `json:"template,omitempty" yaml:",omitempty"` Overrideable `json:",inline" yaml:",inline"` // List of systems this dependency supports. Systems are in the form of os/architecture. Systems []System `json:"systems,omitempty" yaml:"systems,omitempty"` // A list of variables that must be present for an install to succeed RequiredVars []string `json:"required_vars,omitempty" yaml:"required_vars,omitempty"` // contains filtered or unexported fields }
type DependencyOverride ¶
type DependencyOverride struct { // Limits the override to configurations matching all of the matchers. Keys may be "os", "arch" or any variable name. // Values are an array of values to match. Any matching value will match. If a value can be interpreted as a // semantic version it will be treated as such. OverrideMatcher map[string][]string `json:"matcher" yaml:"matcher,omitempty"` // Values to override the parent dependency Dependency Overrideable `json:"dependency" yaml:"dependency,omitempty"` }
type Overrideable ¶
type Overrideable struct { // The url to download a dependency from. URL *string `json:"url,omitempty" yaml:",omitempty"` // The path in the downloaded archive where the binary is located. Default is ./<bin> ArchivePath *string `json:"archive_path,omitempty" yaml:"archive_path,omitempty"` // The name of the binary to be installed. Default is the name of the dependency. BinName *string `json:"bin,omitempty" yaml:"bin,omitempty"` // Whether to create a symlink to the bin instead of copying it. Link *bool `json:"link,omitempty" yaml:",omitempty"` // A list of variables that can be used in 'url', 'archive_path' and 'bin'. // // Two variables are always added based on the current environment: 'os' and 'arch'. Those are the operating // system and architecture as defined by go's GOOS and GOARCH variables. I should document what those are // somewhere. // // You can reference a variable using golang template syntax. For example, you could have a url set to // `https://example.org/mydependency/v{{.version}}/mydependency-{{.os}}-{{.arch}}.tar.gz`. If you define the var // 'version: 1.2.3' and run bindown on a 64-bit Linux system, it will download // `https://example.org/mydependency/v1.2.3/mydependency-linux-amd64.tar.gz`. Vars map[string]string `json:"vars,omitempty" yaml:",omitempty"` // Overrides allows you to override values depending on the os and architecture of the target system. Overrides []DependencyOverride `json:"overrides,omitempty" yaml:",omitempty"` // Substitutions will substitute values from vars. The key is the name of the variable to substitute. The value is // a map of substitutions. { "os": { "linux": "Linux", "darwin": "MacOS" } } is an example of a substitution that // will update the os variable. Substitutions map[string]map[string]string `json:"substitutions,omitempty" yaml:",omitempty"` }