tools

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 19 Imported by: 6

Documentation

Index

Constants

View Source
const (
	OSLinux  = "linux"
	OSDarwin = "darwin"
	OSDocker = "docker"

	ArchAMD64 = "amd64"
	ArchARM64 = "arm64"
)

Platform constants.

Variables

View Source
var (
	PlatformLocal       = Platform{OS: runtime.GOOS, Arch: runtime.GOARCH}
	PlatformLinuxAMD64  = Platform{OS: OSLinux, Arch: ArchAMD64}
	PlatformDarwinAMD64 = Platform{OS: OSDarwin, Arch: ArchAMD64}
	PlatformDarwinARM64 = Platform{OS: OSDarwin, Arch: ArchARM64}
	PlatformDocker      = Platform{OS: OSDocker, Arch: runtime.GOARCH}
	PlatformDockerAMD64 = Platform{OS: OSDocker, Arch: ArchAMD64}
	PlatformDockerARM64 = Platform{OS: OSDocker, Arch: ArchARM64}
)

Platform definitions.

Functions

func Add

func Add(tools ...Tool)

Add adds tools to the toolset.

func Bin

func Bin(ctx context.Context, binary string, platform Platform) string

Bin returns path to the installed binary.

func Checksum

func Checksum(file string) (string, error)

Checksum computes the checksum of a file.

func DevDir

func DevDir(ctx context.Context) string

DevDir returns directory where development files are stored.

func Ensure

func Ensure(ctx context.Context, toolName Name, platform Platform) error

Ensure ensures tool exists for the platform.

func EnsureAll

func EnsureAll(ctx context.Context, _ types.DepsFunc) error

EnsureAll ensures all the tools.

func EnvDir

func EnvDir(ctx context.Context) string

EnvDir returns the directory where local environment is stored.

func GetName

func GetName(ctx context.Context) string

GetName returns name passed to `Main` function

func GetVersion added in v2.1.0

func GetVersion(ctx context.Context) string

GetVersion returns version passed to `Main` function

func LinkFiles

func LinkFiles(ctx context.Context, platform Platform, tool Tool, binaries []string) error

LinkFiles creates all the links for the tool.

func PlatformDir

func PlatformDir(ctx context.Context, platform Platform) string

PlatformDir returns the directory where platform-specific stuff is stored.

func ShouldReinstall

func ShouldReinstall(ctx context.Context, platform Platform, tool Tool, dst, src string) bool

ShouldReinstall check if tool should be reinstalled due to missing files or links.

func ToolDownloadDir

func ToolDownloadDir(ctx context.Context, platform Platform, tool Tool) string

ToolDownloadDir returns directory where tool is downloaded.

func ToolLinksDir

func ToolLinksDir(ctx context.Context, platform Platform, tool Tool) string

ToolLinksDir returns directory where tools should be linked.

func VerifyChecksums

func VerifyChecksums(ctx context.Context, _ types.DepsFunc) error

VerifyChecksums of all the tools.

func VersionDir

func VersionDir(ctx context.Context, platform Platform) string

VersionDir returns path to the version directory.

func WithName

func WithName(ctx context.Context, name string) context.Context

WithName creates context with name embedded.

func WithVersion added in v2.1.0

func WithVersion(ctx context.Context, version string) context.Context

WithVersion creates context with version embedded.

Types

type BinaryTool

type BinaryTool struct {
	Name    Name
	Version string
	Sources Sources
}

BinaryTool is the tool having compiled binaries available on the internet.

func (BinaryTool) Ensure

func (bt BinaryTool) Ensure(ctx context.Context, platform Platform) error

Ensure ensures the tool is installed.

func (BinaryTool) GetName

func (bt BinaryTool) GetName() Name

GetName returns the anme of the tool.

func (BinaryTool) GetVersion

func (bt BinaryTool) GetVersion() string

GetVersion returns the version of the tool.

func (BinaryTool) IsCompatible

func (bt BinaryTool) IsCompatible(platform Platform) (bool, error)

IsCompatible checks if tool is compatible with the platform.

func (BinaryTool) Verify

func (bt BinaryTool) Verify(ctx context.Context) ([]error, error)

Verify verifies the cheksums.

type Name

type Name string

Name is the type used for defining tool names.

type Platform

type Platform struct {
	OS   string
	Arch string
}

Platform defines platform to install tool on.

func (Platform) String

func (p Platform) String() string

type Source

type Source struct {
	URL   string
	Hash  string
	Links map[string]string
}

Source represents source where tool is fetched from.

type Sources

type Sources map[Platform]Source

Sources is the map of sources.

type Tool

type Tool interface {
	GetName() Name
	GetVersion() string
	IsCompatible(platform Platform) (bool, error)
	Verify(ctx context.Context) ([]error, error)
	Ensure(ctx context.Context, platform Platform) error
}

Tool represents a tool to be installed.

func Get

func Get(toolName Name) (Tool, error)

Get returns the tool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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