get

package
v0.0.0-...-083e628 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DownloadTempDir   = iota
	DownloadArkadeDir = iota
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

func CopyFileP

func CopyFileP(src, dst string, permMode int) (int64, error)

func CreateToolsTable

func CreateToolsTable(tools Tools, format TableFormat)

CreateToolTable creates table to show the avaiable CLI tools

func Download

func Download(tool *Tool, arch, operatingSystem, version string, movePath string, displayProgress, quiet bool) (string, string, error)

func DownloadFileP

func DownloadFileP(downloadURL string, displayProgress bool) (string, error)

DownloadFile downloads a file to a temporary directory and returns the path to the file and any error.

func FindGitHubRelease

func FindGitHubRelease(owner, repo string) (string, error)

func GetBinaryName

func GetBinaryName(tool *Tool, os, arch, version string) (string, error)

GetBinaryName returns the name of a binary for the given tool or an error if the tool's template cannot be parsed or executed.

func GetDownloadURL

func GetDownloadURL(tool *Tool, os, arch, version string, quiet bool) (string, error)

GetDownloadURL fetches the download URL for a release of a tool for a given os, architecture and version

func GetToolVersion

func GetToolVersion(tool *Tool, version string) string

func PostInstallationMsg

func PostInstallationMsg(movePath string, localToolsStore []ToolLocal) ([]byte, error)

PostInstallationMsg generates installation message after tool has been downloaded

func PostToolNotFoundMsg

func PostToolNotFoundMsg(url string) string

func ValidateArch

func ValidateArch(name string) error

ValidateArch returns whether a given cpu architecture is supported

func ValidateOS

func ValidateOS(name string) error

ValidateOS returns whether a given operating system is supported

Types

type ErrNotFound

type ErrNotFound struct {
}

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

type TableFormat

type TableFormat string
const (
	TableStyle    TableFormat = "table"
	MarkdownStyle TableFormat = "markdown"
	ListStyle     TableFormat = "list"
)

type Tool

type Tool struct {
	// The name of the tool for download
	Name string

	// Repo is a GitHub repo, when no repo exists, use the same
	// as the name.
	Repo string

	// Owner is the name of the GitHub account, when no account
	// exists, use the vendor name lowercase.
	Owner string

	// Version pinned or left empty to pull the latest release
	// if any only if only BinaryTemplate is specified.
	Version string

	// Bespoke approach for finding version when none is set.
	VersionStrategy string

	// Description of what the tool is used for.
	Description string

	// URLTemplate specifies a Go template for the download URL
	// override the OS, architecture and extension
	// All whitespace will be trimmed/
	URLTemplate string

	// The binary template can be used when downloading GitHub
	// It assumes that the only part of the URL needing to be
	// templated is the binary name on a standard GitHub download
	// URL.
	BinaryTemplate string

	// NoExtension is required for tooling such as kubectx
	// which at time of writing is a bash script.
	NoExtension bool
}

Tool describes how to download a CLI tool from a binary release - whether a single binary, or an archive.

func (Tool) GetURL

func (tool Tool) GetURL(os, arch, version string, quiet bool) (string, error)

func (Tool) Head

func (tool Tool) Head(uri string) (int, string, http.Header, error)

func (Tool) IsArchive

func (tool Tool) IsArchive(quiet bool) (bool, error)

type ToolLocal

type ToolLocal struct {
	Name string
	Path string
}

type Tools

type Tools []Tool

func GetDownloadURLs

func GetDownloadURLs(tools Tools, toolArgs []string, version string) (Tools, error)

GetDownloadURLs generates a list of URL for each tool, for download

func MakeTools

func MakeTools() Tools

func (Tools) Len

func (t Tools) Len() int

func (Tools) Less

func (t Tools) Less(i, j int) bool

func (Tools) Swap

func (t Tools) Swap(i, j int)

Jump to

Keyboard shortcuts

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