program

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClearCache bool

ClearCache variable for clear-cache flag

Functions

func IsLatestVersion

func IsLatestVersion(p IProgram) bool

IsLatestVersion returns true if installed program is latest version.

func NewGithubClient

func NewGithubClient() (*github.Client, context.Context)

NewGithubClient returns github.Client with auth if available otherwise unauthenticated

Types

type Command

type Command struct {
	Path          string
	Cmd           string
	VersionArg    string
	VersionRegexp string
}

Command defines command, version args and regexp to find version number.

func (*Command) GetCmd

func (p *Command) GetCmd() string

GetCmd returns the command name

func (*Command) GetFullPath

func (p *Command) GetFullPath() string

GetFullPath returns the full path to the command

func (*Command) GetLocalVersion

func (p *Command) GetLocalVersion() string

GetLocalVersion runs Cmd with versionArg and finds version using versionRegexp, which it returns.

func (*Command) IsInstalled

func (p *Command) IsInstalled() bool

IsInstalled checks if command is installed and returns boolean

type GithubDirectDownloadProgram

type GithubDirectDownloadProgram struct {
	GithubProgram
}

GithubDirectDownloadProgram downloads a file directly

func (*GithubDirectDownloadProgram) DownloadLatestVersion

func (p *GithubDirectDownloadProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads the latest release and puts it into the bindir

type GithubDownloadUntarFileProgram

type GithubDownloadUntarFileProgram struct {
	GithubProgram
	Filename string
}

GithubDownloadUntarFileProgram downloads a tarball and extracts a single file from it

func (*GithubDownloadUntarFileProgram) DownloadLatestVersion

func (p *GithubDownloadUntarFileProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and untars a file to the bindir

type GithubDownloadUnzipFileProgram

type GithubDownloadUnzipFileProgram struct {
	GithubProgram
	Filename string
}

GithubDownloadUnzipFileProgram downloads a zip-file and extracts a single file from it

func (*GithubDownloadUnzipFileProgram) DownloadLatestVersion

func (p *GithubDownloadUnzipFileProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and unzips a file to the bindir

type GithubProgram

type GithubProgram struct {
	Command
	GithubOwner string
	GithubRepo  string
	ReleaseName string // Will be appended when generating Github download URL. Ex: kustomize_{VERSION}_linux_amd64
	DownloadURL string // Optional, will be used instead of generating URL.
	PreRelease  bool   // Accept prereleases. Defaults to false
	TagName     string // Optional, will be used to find release. Ex: kustomize will find kustomize/v3.3.0. Used when multiple programs are released from the same repo.
}

GithubProgram is a Program released via Github

func (*GithubProgram) GetLatestVersion

func (p *GithubProgram) GetLatestVersion() (string, string, error)

GetLatestVersion returns the latest version available

type HashicorpProgram

type HashicorpProgram struct {
	Command
}

HashicorpProgram is for Hashicorp programs

func (*HashicorpProgram) DownloadLatestVersion

func (p *HashicorpProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and extracts the latest version

func (*HashicorpProgram) GetLatestVersion

func (p *HashicorpProgram) GetLatestVersion() (string, string, error)

GetLatestVersion returns the latest version number available

type IProgram

type IProgram interface {
	GetCmd() string
	GetFullPath() string
	GetLocalVersion() string
	GetLatestVersion() (string, string, error)
	IsInstalled() bool
	DownloadLatestVersion() string
}

IProgram defines a program

Jump to

Keyboard shortcuts

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