forked from bmatcuk/go-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_provision.go
40 lines (35 loc) · 1.04 KB
/
command_provision.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package vagrant
// ProvisionCommand specifies the options and output of vagrant provision
type ProvisionCommand struct {
BaseCommand
MachineNameArgument
ErrorResponse
ProvisionersArgument
}
// Provision will run the provisioners in a Vagrantfile. After setting options
// as appropriate, you must call Run() or Start() followed by Wait() to
// execute. Errors will be recorded in Error.
func (client *VagrantClient) Provision() *ProvisionCommand {
return &ProvisionCommand{
BaseCommand: newBaseCommand(client),
ErrorResponse: newErrorResponse(),
}
}
func (cmd *ProvisionCommand) init() error {
args := cmd.appendMachineName(cmd.buildArguments())
return cmd.BaseCommand.init(&cmd.ErrorResponse, "provision", args...)
}
// Run the command
func (cmd *ProvisionCommand) Run() error {
if err := cmd.Start(); err != nil {
return err
}
return cmd.Wait()
}
// Start the command. You must call Wait() to complete execution.
func (cmd *ProvisionCommand) Start() error {
if err := cmd.init(); err != nil {
return err
}
return cmd.BaseCommand.Start()
}