tools

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CacheDirectory = filepath.Join(xdg.CacheHome(), "go-clitools", "cache")
	BinDirectory   = filepath.Join(xdg.DataHome(), "go-clitools", "bin")
	CacheTimeout   = time.Hour * 24 * 7
)
View Source
var (
	ErrFailedToDetermineVersion = errors.New("failed to determine error version")
)
View Source
var (
	ErrNoVersionConstraintSupport = errors.New("semver version constraints are not supported by this downloader")
)

Functions

func CmdRan

func CmdRan(err error) bool

CmdRan examines the error to determine if it was generated as a result of a command running via os/exec.Command. If the error is nil, or the command ran (even if it exited with a non-zero exit code), CmdRan reports true. If the error is an unrecognized type, or it is an error from exec.Command that says the command failed to run (usually due to the command not existing or not being executable), it reports false.

func GetExitStatus

func GetExitStatus(err error) int

GetExitStatus returns the exit status of the error if it is an exec.ExitErr or if it implements ExitStatus. It returns 0 if err is nil or 1 if it is an unrecognized error type

func MustResolveTool

func MustResolveTool(tool ToolInfo, version string, providers ...ToolProvider) string

func ResolveTool

func ResolveTool(tool ToolInfo, version string, providers ...ToolProvider) (string, error)

Types

type ChainToolProvider

type ChainToolProvider struct {
	Providers []ToolProvider
}

func (*ChainToolProvider) GetPath

func (p *ChainToolProvider) GetPath(tool ToolInfo, version string) (string, error)

func (*ChainToolProvider) GetPathWithConstraint

func (p *ChainToolProvider) GetPathWithConstraint(tool ToolInfo, constraints *semver.Constraints) (string, error)

func (*ChainToolProvider) GetPathWithVersion

func (p *ChainToolProvider) GetPathWithVersion(tool ToolInfo, version *semver.Version) (string, error)

type CommandContext

type CommandContext struct {
	Path string
	Args []string
}

func (*CommandContext) Exec

func (c *CommandContext) Exec(stdout, stderr io.Writer, opts ...CommandOption) (ran bool, exitCode int, err error)

func (*CommandContext) ExecContext

func (c *CommandContext) ExecContext(ctx context.Context, stdout, stderr io.Writer, opts ...CommandOption) (ran bool, exitCode int, err error)

func (*CommandContext) Run

func (c *CommandContext) Run(opts ...CommandOption) error

func (*CommandContext) RunContext

func (c *CommandContext) RunContext(ctx context.Context, opts ...CommandOption) error

func (*CommandContext) RunOutput

func (c *CommandContext) RunOutput(opts ...CommandOption) (string, error)

func (*CommandContext) RunOutputContext

func (c *CommandContext) RunOutputContext(ctx context.Context, opts ...CommandOption) (string, error)

func (*CommandContext) RunV

func (c *CommandContext) RunV(opts ...CommandOption) error

RunV always outputs to Stdout and Stderr

func (*CommandContext) RunVContext

func (c *CommandContext) RunVContext(ctx context.Context, opts ...CommandOption) error

RunVContext always outputs to Stdout and Stderr

type CommandOption

type CommandOption = func(c *command)

func IgnoreOSEnvironment

func IgnoreOSEnvironment() CommandOption

func SetEnvironmentVariables

func SetEnvironmentVariables(env map[string]string) CommandOption

func SetLogger

func SetLogger(logger Logger) CommandOption

func SetNOOPLogger

func SetNOOPLogger() CommandOption

func SetStdin added in v0.0.6

func SetStdin(stdin io.Reader) CommandOption

func SetWorkingDirectory

func SetWorkingDirectory(wd string) CommandOption

type DefinedPathToolProvider

type DefinedPathToolProvider string

func (DefinedPathToolProvider) GetPath

func (p DefinedPathToolProvider) GetPath(tool ToolInfo, version string) (string, error)

func (DefinedPathToolProvider) GetPathWithConstraint

func (p DefinedPathToolProvider) GetPathWithConstraint(tool ToolInfo, constraints *semver.Constraints) (string, error)

func (DefinedPathToolProvider) GetPathWithVersion

func (p DefinedPathToolProvider) GetPathWithVersion(tool ToolInfo, version *semver.Version) (string, error)

type Downloader

type Downloader interface {
	Download(version string) (string, error)
	DownloadWithVersion(version *semver.Version) (string, error)
	DownloadWithConstraints(constraints *semver.Constraints) (string, error)
}

type DownloaderToolProvider

type DownloaderToolProvider struct {
	Downloader Downloader
}

func (*DownloaderToolProvider) GetPath

func (p *DownloaderToolProvider) GetPath(tool ToolInfo, version string) (string, error)

func (*DownloaderToolProvider) GetPathWithConstraint

func (p *DownloaderToolProvider) GetPathWithConstraint(tool ToolInfo, constraints *semver.Constraints) (string, error)

func (*DownloaderToolProvider) GetPathWithVersion

func (p *DownloaderToolProvider) GetPathWithVersion(tool ToolInfo, version *semver.Version) (string, error)

type ExitStatus

type ExitStatus interface {
	ExitStatus() int
}

type GithubReleaseDownloader

type GithubReleaseDownloader struct {
	Tool           string
	ToolExecutable string
	Owner          string
	Repository     string
	TagPrefix      string

	AssetSelector       string
	AssetSelectorRegexp bool
	Archived            bool
	ArchivePath         string

	MultipleReleases          bool
	MultipleReleasesTagPrefix string
}

func (*GithubReleaseDownloader) Download

func (d *GithubReleaseDownloader) Download(version string) (string, error)

func (*GithubReleaseDownloader) DownloadWithConstraints

func (d *GithubReleaseDownloader) DownloadWithConstraints(constraints *semver.Constraints) (string, error)

func (*GithubReleaseDownloader) DownloadWithVersion

func (d *GithubReleaseDownloader) DownloadWithVersion(version *semver.Version) (string, error)

type Logger

type Logger interface {
	Log(cmdPath string, args []string, env []string)
}
var DefaultLogger Logger = SimpleLogger{}

type NOOPLogger

type NOOPLogger struct{}

func (NOOPLogger) Log

func (NOOPLogger) Log(cmdPath string, args []string, env []string)

type PathToolProvider

type PathToolProvider struct {
}

func (PathToolProvider) GetPath

func (p PathToolProvider) GetPath(tool ToolInfo, version string) (string, error)

func (PathToolProvider) GetPathWithConstraint

func (p PathToolProvider) GetPathWithConstraint(tool ToolInfo, constraints *semver.Constraints) (string, error)

func (PathToolProvider) GetPathWithVersion

func (p PathToolProvider) GetPathWithVersion(tool ToolInfo, version *semver.Version) (string, error)

type SimpleLogger

type SimpleLogger struct{}

func (SimpleLogger) Log

func (SimpleLogger) Log(cmdPath string, args []string, env []string)

type ToolInfo

type ToolInfo interface {
	Name() string
	ExecutableName() string
	GetVersion(tp ToolProvider) (string, error)
	GetVersionWithPath(path string) (string, error)
}

type ToolProvider

type ToolProvider interface {
	GetPath(tool ToolInfo, version string) (string, error)
	GetPathWithVersion(tool ToolInfo, version *semver.Version) (string, error)
	GetPathWithConstraint(tool ToolInfo, constraints *semver.Constraints) (string, error)
}
var DefaultToolProvider ToolProvider = PathToolProvider{}

Directories

Path Synopsis
Go is a tool for managing go source code.
Go is a tool for managing go source code.
env
fix
get
mod
Go mod provides access to operations on modules.
Go mod provides access to operations on modules.
run
vet
Deliver Go binaries as fast and easily as possible
Deliver Go binaries as fast and easily as possible
k3d
cluster
Manage cluster(s)
Manage cluster(s)
config
Work with config file(s)
Work with config file(s)
image
Handle container images.
Handle container images.
kubeconfig
Manage kubeconfig(s)
Manage kubeconfig(s)
node
Manage node(s)
Manage node(s)
A FAST Kubernetes manifests validator, with support for Custom Resources!
A FAST Kubernetes manifests validator, with support for Custom Resources!
Manages declarative configuration of Kubernetes.
Manages declarative configuration of Kubernetes.
cfg
Commands for reading and writing configuration
Commands for reading and writing configuration
edit
Edits a kustomization file
Edits a kustomization file
edit/add
Adds an item to the kustomization file.
Adds an item to the kustomization file.
edit/remove
Removes items from the kustomization file.
Removes items from the kustomization file.
edit/set
Sets the value of different fields in kustomization file.
Sets the value of different fields in kustomization file.
Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects.
Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects.
add
run
Correct commonly misspelled English words...
Correct commonly misspelled English words...
svu
Semantic Version Util is a tool to manage semantic versions at ease!
Semantic Version Util is a tool to manage semantic versions at ease!

Jump to

Keyboard shortcuts

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