hashitools

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2015 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type GoInstaller

type GoInstaller struct {
	// Name is the name of the project to install
	Name string

	// Dir is the directory where projects will be installed. They will
	// be installed to a sub-directory of the project name. Example:
	// if Dir is "/foo", then the Packer binary would be installed to
	// "/foo/packer/packer"
	Dir string

	// Ui is the Otto UI for asking the user for input and outputting
	// the status of installation.
	Ui ui.Ui
}

GoInstaller is an Installer that knows how to install Go projects.

func (*GoInstaller) Install

func (i *GoInstaller) Install(vsn *version.Version) error

func (*GoInstaller) InstallAsk

func (i *GoInstaller) InstallAsk(installed, required, latest *version.Version) (bool, error)

func (*GoInstaller) Path

func (i *GoInstaller) Path() string

type Installer

type Installer interface {
	// InstallAsk should ask the user if they'd like to install the
	// project. This is only called if installation is actually required.
	InstallAsk(installed, required, latest *version.Version) (bool, error)

	// Install should install the specified version.
	Install(*version.Version) error

	// Path is the path to the installed main binary of this project,
	// or "" if it doesn't seem installed.
	Path() string
}

Installer is the interface that knows how to install things.

This is an interface to support different installation methods between our different projects.

type Project

type Project struct {
	// Name is the name of the project, all lowercase
	Name string

	// Installer is the installer for this project
	Installer Installer

	// MinVersion is the minimum version of this project that Otto
	// can use to function. This will be used with `InstallIfNeeded`
	// to prompt the user to install.
	MinVersion *version.Version
}

Project represents a HashiCorp Go project and provides various operations around that.

func (*Project) InstallIfNeeded

func (p *Project) InstallIfNeeded() error

InstallIfNeeded will check if installation of this project is required and will invoke the installer if needed.

func (*Project) LatestVersion

func (p *Project) LatestVersion() (*version.Version, error)

Latest version returns the latest version of this project.

func (*Project) Path

func (p *Project) Path() string

Path returns the path to this project. This will check if the project binary is pre-installed in our installation directory and use that path. Otherwise, it will return the raw project name.

func (*Project) Version

func (p *Project) Version() (*version.Version, error)

Version reads the version of this project.

type VagrantInstaller

type VagrantInstaller struct {
	// Ui is the Otto UI for asking the user for input and outputting
	// the status of installation.
	Ui ui.Ui
}

VagrantInstaller is an Installer that knows how to install Vagrant, which uses its own system installer.

func (*VagrantInstaller) Install

func (i *VagrantInstaller) Install(vsn *version.Version) error

func (*VagrantInstaller) InstallAsk

func (i *VagrantInstaller) InstallAsk(installed, required, latest *version.Version) (bool, error)

func (*VagrantInstaller) Path

func (i *VagrantInstaller) Path() string

Jump to

Keyboard shortcuts

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