tool

package
v0.0.0-...-ec5dca2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(
	basePath, version string, force, windows bool, max uint, b Binary,
	f download.FileFetcher,
) (s string, err error)

func Installed

func Installed(basePath, binary, version string) (bool, error)

Installed checks if a binary version is already downloaded. While walking through the paths, it also checks to make sure that the path is valid. If a binary is found at the end of the path, it returns true

func LinkedVersion

func LinkedVersion(basePath, binary string) (string, error)

LinkedVersion checks if a binary is symlinked, and returns the version symlinked It returns an error if the binary is not symlinked The symlink we are checking could exist in three states, "existing", "broken", and "not existing" "existing" is a happy symlink. Symlink exists, and the link is not broken "broken" is a sad symlink. Symlink exists, and the link not broken "not existing" is depressed symlink. Symlink does not exist, but it's ok

func ListInstalled

func ListInstalled(basePath string) ([]string, error)

ListInstalled returns the list of installed binaries

func ListToolVersionsInstalled

func ListToolVersionsInstalled(basePath, binary string) ([]string, error)

ListToolVersionsInstalled will list all of the downloaded versions of a binary

func Purge

func Purge(basePath, binary string) error

Purge will remove all binary versions at the provided path

func RemoveVersions

func RemoveVersions(basePath string, binary string, versions []string) error

RemoveVersions will remove the binary version at the provided path basePath is the path where the .kpkg folder is located binary is the binary name versions is a list of versions to remove

Types

type Binary

type Binary interface {
	// Name returns the name of the binary
	Name() string

	// ShortDesc returns a short description of the binary
	ShortDesc() string

	// LongDesc returns a long description of the binary
	LongDesc() string

	// Given a version, it returns a url to fetch the file
	MakeUrl(version string) (string, error)

	// Versions lists the possible installation candidates for a source like Github releases.
	// It gives a sorted slice, based of stability. For example, all of the stable releases will appear
	// before a beta release, and all of the beta releases will appear before the alpha releases. The sorting
	//  is implementation specific.
	Versions(max uint) ([]string, error)

	// Extract takes the downloaded artifacts and does some processing on it to extract the binary.
	// This is useful for binaries like helm, where a tar file is downloaded,
	// containing a LICENSE file, a README file and the helm binary. This method would allow for
	// extracting just the binary before installing. Note that this is called after the artifacts
	// have already been downloaded, so this means that the downloaded file will already by
	// unzipped and/or un-tarred.
	Extract(artifactPath, version string) (string, error)
}

Binary is an interface that all binaries must implement

type GithubReleaseTool

type GithubReleaseTool struct {
	Owner, Repo string
}

func MakeGithubReleaseTool

func MakeGithubReleaseTool(org, repo string) GithubReleaseTool

func (GithubReleaseTool) Extract

func (l GithubReleaseTool) Extract(artifactPath, _ string) (string, error)

func (GithubReleaseTool) MakeReleaseUrl

func (l GithubReleaseTool) MakeReleaseUrl() string

func (GithubReleaseTool) Versions

func (l GithubReleaseTool) Versions(max uint) ([]string, error)

Jump to

Keyboard shortcuts

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