program

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 {
	Command
	GithubProgram
}

GithubDirectDownloadProgram downloads a file directly

func NewGithubDirectDownloadProgram

func NewGithubDirectDownloadProgram(
	cmd string,
	path string,
	versionArg string,
	versionRegexp string,
	githubOwner string,
	githubRepo string,
	releaseName string,
	prerelease bool,
	downloadURL string) *GithubDirectDownloadProgram

NewGithubDirectDownloadProgram returns a new GithubDirectDownloadProgram

func (*GithubDirectDownloadProgram) DownloadLatestVersion

func (p *GithubDirectDownloadProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads the latest release and puts it into the bindir

type GithubDownloadUntarFileProgram

type GithubDownloadUntarFileProgram struct {
	Command
	GithubProgram
	Filename string
}

GithubDownloadUntarFileProgram downloads a tarball and extracts a single file from it

func NewGithubDownloadUntarFileProgram

func NewGithubDownloadUntarFileProgram(
	cmd string,
	path string,
	versionArg string,
	versionRegexp string,
	githubOwner string,
	githubRepo string,
	releaseName string,
	prerelease bool,
	downloadURL string,
	filename string) *GithubDownloadUntarFileProgram

NewGithubDownloadUntarFileProgram returns a new GithubDirectDownloadProgram

func (*GithubDownloadUntarFileProgram) DownloadLatestVersion

func (p *GithubDownloadUntarFileProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and untars a file to the bindir

type GithubDownloadUnzipFileProgram

type GithubDownloadUnzipFileProgram struct {
	Command
	GithubProgram
	Filename string
}

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

func NewGithubDownloadUnzipFileProgram

func NewGithubDownloadUnzipFileProgram(
	cmd string,
	path string,
	versionArg string,
	versionRegexp string,
	githubOwner string,
	githubRepo string,
	releaseName string,
	prerelease bool,
	downloadURL string,
	filename string) *GithubDownloadUnzipFileProgram

NewGithubDownloadUnzipFileProgram returns a new GithubDirectDownloadProgram

func (*GithubDownloadUnzipFileProgram) DownloadLatestVersion

func (p *GithubDownloadUnzipFileProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and unzips a file to the bindir

type GithubProgram

type GithubProgram struct {
	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
}

GithubProgram is a Program released via Github

func (*GithubProgram) GetLatestDownloadURL

func (p *GithubProgram) GetLatestDownloadURL() string

GetLatestDownloadURL returns the URL to download the latest release

func (*GithubProgram) GetLatestVersion

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

GetLatestVersion returns the latest version available

type HashicorpProgram

type HashicorpProgram struct {
	Command
}

HashicorpProgram is for Hashicorp programs

func NewHashicorpProgram

func NewHashicorpProgram(
	cmd string,
	path string,
	versionRegexp string) *HashicorpProgram

NewHashicorpProgram returns a new HashicorpProgram

func (*HashicorpProgram) DownloadLatestVersion

func (p *HashicorpProgram) DownloadLatestVersion() string

DownloadLatestVersion downloads and extracts the latest version

func (*HashicorpProgram) GetLatestDownloadURL

func (p *HashicorpProgram) GetLatestDownloadURL() string

GetLatestDownloadURL return the URL to download the latest version from

func (*HashicorpProgram) GetLatestVersion

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

GetLatestVersion returns the latest version number available

type IProgram

type IProgram interface {
	GetCmd() string
	GetFullPath() string
	GetLocalVersion() string
	GetLatestVersion() (string, error)
	GetLatestDownloadURL() string
	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