bindown

package
v3.20.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransformMap

func TransformMap[K comparable, V, W any](m map[K]V, fn func(V) W) map[K]W

func TransformSlice

func TransformSlice[T, V any](s []T, fn func(T) V) []V

Types

type AddDependencyFromTemplateOpts

type AddDependencyFromTemplateOpts struct {
	TemplateSource string
	DependencyName string
	Vars           map[string]string
}

AddDependencyFromTemplateOpts options for AddDependencyFromTemplate

type Config

type Config struct {
	Cache           string                 `json:"cache,omitempty" yaml:"cache,omitempty"`
	TrustCache      bool                   `json:"trust_cache,omitempty" yaml:"trust_cache,omitempty"`
	InstallDir      string                 `json:"install_dir,omitempty" yaml:"install_dir,omitempty"`
	Systems         []SystemInfo           `json:"systems,omitempty" yaml:"systems,omitempty"`
	Dependencies    map[string]*Dependency `json:"dependencies,omitempty" yaml:",omitempty"`
	Templates       map[string]*Dependency `json:"templates,omitempty" yaml:",omitempty"`
	TemplateSources map[string]string      `json:"template_sources,omitempty" yaml:"template_sources,omitempty"`
	URLChecksums    map[string]string      `json:"url_checksums,omitempty" yaml:"url_checksums,omitempty"`
}

Config is our main config

func ConfigFromURL

func ConfigFromURL(ctx context.Context, cfgSrc string) (*Config, error)

ConfigFromURL loads a config from a URL

func (*Config) AddChecksums

func (c *Config) AddChecksums(dependencies []string, systems []SystemInfo) error

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) error

AddDependencyFromTemplate adds a dependency to the config

func (*Config) BinName

func (c *Config) BinName(depName string, system SystemInfo) (string, error)

BinName returns the bin name for a downloader on a given system

func (*Config) BuildDependency

func (c *Config) BuildDependency(depName string, info SystemInfo) (*Dependency, error)

BuildDependency returns a dependency with templates and overrides applied and variables interpolated for the given system.

func (*Config) ClearCache

func (c *Config) ClearCache() error

func (*Config) CopyTemplateFromSource

func (c *Config) CopyTemplateFromSource(ctx context.Context, src, srcTemplate, destName string) error

CopyTemplateFromSource copies a template from source

func (*Config) DefaultSystems

func (c *Config) DefaultSystems() []SystemInfo

DefaultSystems returns c.Systems if it isn't empty. Otherwise returns the runtime system.

func (*Config) DependencySystems

func (c *Config) DependencySystems(depName string) ([]SystemInfo, error)

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,
	sysInfo SystemInfo,
	opts *ConfigDownloadDependencyOpts,
) (_ string, errOut error)

DownloadDependency downloads a dependency

func (*Config) ExtractDependency

func (c *Config) ExtractDependency(dependencyName string, sysInfo SystemInfo, opts *ConfigExtractDependencyOpts) (_ string, errOut error)

ExtractDependency downloads and extracts a dependency

func (*Config) InstallDependency

func (c *Config) InstallDependency(dependencyName string, sysInfo SystemInfo, opts *ConfigInstallDependencyOpts) (_ string, errOut error)

InstallDependency downloads, extracts and installs a dependency

func (*Config) ListTemplates

func (c *Config) ListTemplates(ctx context.Context, templateSource string) ([]string, error)

ListTemplates lists templates available in this config or one of its template sources.

func (*Config) MissingDependencyVars

func (c *Config) MissingDependencyVars(depName string) ([]string, error)

MissingDependencyVars returns a list of vars that are required but undefined

func (*Config) PruneChecksums

func (c *Config) PruneChecksums() error

PruneChecksums removes checksums for dependencies that are not used by any configured system.

func (*Config) SetDependencyVars

func (c *Config) SetDependencyVars(depName string, vars map[string]string) error

SetDependencyVars sets the value of a dependency's var. Adds or Updates the var.

func (*Config) SetTemplateVars

func (c *Config) SetTemplateVars(tmplName string, vars map[string]string) error

SetTemplateVars sets the value of a template's var. Adds or Updates the var.

func (*Config) UnsetDependencyVars

func (c *Config) UnsetDependencyVars(depName string, vars []string) error

UnsetDependencyVars removes a dependency var. Noop if the var doesn't exist.

func (*Config) UnsetTemplateVars

func (c *Config) UnsetTemplateVars(tmplName string, vars []string) error

UnsetTemplateVars removes a template var. Noop if the var doesn't exist.

func (*Config) Validate

func (c *Config) Validate(dependencies []string, systems []SystemInfo) (errOut error)

Validate installs the downloader to a temporary directory and returns an error if it was unsuccessful.

type ConfigDownloadDependencyOpts

type ConfigDownloadDependencyOpts struct {
	TargetFile           string
	Force                bool
	AllowMissingChecksum bool
}

ConfigDownloadDependencyOpts options for Config.DownloadDependency

type ConfigExtractDependencyOpts

type ConfigExtractDependencyOpts struct {
	TargetDirectory      string
	Force                bool
	AllowMissingChecksum bool
}

ConfigExtractDependencyOpts options for Config.ExtractDependency

type ConfigFile

type ConfigFile struct {
	Filename string `json:"-"`
	Config
}

ConfigFile is a file containing config

func LoadConfigFile

func LoadConfigFile(ctx context.Context, filename string, noDefaultDirs bool) (*ConfigFile, error)

LoadConfigFile loads a config file

func (*ConfigFile) Write

func (c *ConfigFile) Write(outputJSON bool) error

Write writes a file to disk

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 {
	Homepage      *string                      `json:"homepage,omitempty" yaml:",omitempty"`
	Description   *string                      `json:"description,omitempty" yaml:",omitempty"`
	Template      *string                      `json:"template,omitempty" yaml:",omitempty"`
	URL           *string                      `json:"url,omitempty" yaml:",omitempty"`
	ArchivePath   *string                      `json:"archive_path,omitempty" yaml:"archive_path,omitempty"`
	BinName       *string                      `json:"bin,omitempty" yaml:"bin,omitempty"`
	Link          *bool                        `json:"link,omitempty" yaml:",omitempty"`
	Vars          map[string]string            `json:"vars,omitempty" yaml:",omitempty"`
	RequiredVars  []string                     `json:"required_vars,omitempty" yaml:"required_vars,omitempty"`
	Overrides     []DependencyOverride         `json:"overrides,omitempty" yaml:",omitempty"`
	Substitutions map[string]map[string]string `json:"substitutions,omitempty" yaml:",omitempty"`
	Systems       []SystemInfo                 `json:"systems,omitempty" yaml:"systems,omitempty"`
}

Dependency is something to download, extract and install

func (*Dependency) Clone

func (d *Dependency) Clone() *Dependency

type DependencyOverride

type DependencyOverride struct {
	OverrideMatcher OverrideMatcher `json:"matcher" yaml:"matcher,omitempty"`
	Dependency      Dependency      `json:"dependency" yaml:",omitempty"`
}

DependencyOverride overrides a dependency's configuration

func (*DependencyOverride) Clone

type OverrideMatcher

type OverrideMatcher map[string][]string

OverrideMatcher contains a list or oses and arches to match an override. If either os or arch is empty, all oses and arches match.

func (OverrideMatcher) Clone

func (o OverrideMatcher) Clone() OverrideMatcher

type SystemInfo

type SystemInfo struct {
	OS   string
	Arch string
}

SystemInfo contains os and architecture for a target system

func (SystemInfo) MarshalText

func (s SystemInfo) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler

func (*SystemInfo) String

func (s *SystemInfo) String() string

func (*SystemInfo) UnmarshalText

func (s *SystemInfo) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

Jump to

Keyboard shortcuts

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