Documentation ¶
Overview ¶
Package vagrantutil is a high level wrapper around Vagrant which provides an idiomatic go API.
Index ¶
- Variables
- func Wait(out <-chan *CommandOutput, err error) error
- type Box
- type CommandOutput
- type Status
- type Vagrant
- func (v *Vagrant) BoxAdd(box *Box) (<-chan *CommandOutput, error)
- func (v *Vagrant) BoxList() ([]*Box, error)
- func (v *Vagrant) BoxRemove(box *Box) (<-chan *CommandOutput, error)
- func (v *Vagrant) Create(vagrantFile string) error
- func (v *Vagrant) Destroy() (<-chan *CommandOutput, error)
- func (v *Vagrant) Halt() (<-chan *CommandOutput, error)
- func (v *Vagrant) List() ([]*Vagrant, error)
- func (v *Vagrant) Provider() (string, error)
- func (v *Vagrant) SSH(command string) (<-chan *CommandOutput, error)
- func (v *Vagrant) SSHConfig() (string, error)
- func (v *Vagrant) Status() (s Status, err error)
- func (v *Vagrant) Up() (<-chan *CommandOutput, error)
- func (v *Vagrant) Version() (string, error)
- type Waiter
Constants ¶
This section is empty.
Variables ¶
var ( ErrBoxAlreadyExists = errors.New("box already exists") ErrBoxInvalidVersion = errors.New("invalid box version") ErrBoxNotAvailable = errors.New("box is not available") ErrBoxDownload = errors.New("unable to download the box") ErrVirtualBox = errors.New("VirtualBox is missing or not operational") )
The following errors are returned by the Wait function:
Functions ¶
func Wait ¶
func Wait(out <-chan *CommandOutput, err error) error
Wait is a convenience function that consumes Vagrant output looking for well-known errors.
Types ¶
type CommandOutput ¶
CommandOutput is the streaming output of a command
type Status ¶
type Status int
const ( // Some possible states: // https://github.com/mitchellh/vagrant/blob/master/templates/locales/en.yml#L1504 Unknown Status = iota NotCreated Running Saved PowerOff Aborted Preparing )
type Vagrant ¶
type Vagrant struct { // VagrantfilePath is the directory with specifies the directory where // Vagrantfile is being stored. VagrantfilePath string // ProviderName overwrites the default provider used for the Vagrantfile. ProviderName string // ID is the unique ID of the given box. ID string // State is populated/updated if the Status() or List() method is called. State string }
func NewVagrant ¶
NewVagrant returns a new Vagrant instance for the given path. The path should be unique. If the path already exists in the system it'll be used, if not a new setup will be createad.
func (*Vagrant) BoxAdd ¶
func (v *Vagrant) BoxAdd(box *Box) (<-chan *CommandOutput, error)
BoxAdd executes "vagrant box add" for the given box. The returned channel contains the output stream. At the end of the output, the error is put into the Error field if there is any.
TODO(rjeczalik): BoxAdd does not support currently adding boxes directly from files.
func (*Vagrant) BoxList ¶
BoxList executes "vagrant box list", parses the output and returns all available base boxes.
func (*Vagrant) BoxRemove ¶
func (v *Vagrant) BoxRemove(box *Box) (<-chan *CommandOutput, error)
BoxRemove executes "vagrant box remove" for the given box. The returned channel contains the output stream. At the end of the output, the error is put into the Error field if there is any.
func (*Vagrant) Destroy ¶
func (v *Vagrant) Destroy() (<-chan *CommandOutput, error)
Destroy executes "vagrant destroy". The returned reader contains the output stream. The client is responsible of calling the Close method of the returned reader.
func (*Vagrant) Halt ¶
func (v *Vagrant) Halt() (<-chan *CommandOutput, error)
Halt executes "vagrant halt". The returned reader contains the output stream. The client is responsible of calling the Close method of the returned reader.
func (*Vagrant) List ¶
List returns all available boxes on the system. Under the hood it calls "global-status" and parses the output.
func (*Vagrant) SSH ¶
func (v *Vagrant) SSH(command string) (<-chan *CommandOutput, error)
SSH executes "vagrant ssh" for the given vagrantfile. The returned channel contains the output stream. At the end of the output, the error is put into the Error field if there is any.
func (*Vagrant) Status ¶
Status returns the state of the box, such as "Running", "NotCreated", etc...
func (*Vagrant) Up ¶
func (v *Vagrant) Up() (<-chan *CommandOutput, error)
Up executes "vagrant up" for the given vagrantfile. The returned channel contains the output stream. At the end of the output, the error is put into the Error field if there is any.
type Waiter ¶
type Waiter struct { // OutputFunc, when non-nil, is called each time a Wait method receives // a line of output from command channel. OutputFunc func(string) }
Waiter is used to consume output channel from a Vagrant command, parsing each line looking for an error when command execution fails.
func (*Waiter) Wait ¶
func (w *Waiter) Wait(out <-chan *CommandOutput, err error) error
Wait is a convenience method that consumes Vagrant output looking for well-known errors.
It returns an error variable for any known error condition, which makes it easier for the caller to recover from failure.
If OutputFunc is non-nil, it's called on each line of output received from the out channel.