commends, documentation and var names updates

This commit is contained in:
bugbuilder 2017-07-19 00:44:18 -04:00
parent fa10616f57
commit 7274bbb63d
6 changed files with 16 additions and 15 deletions

View File

@ -25,7 +25,7 @@ type Config struct {
Insecure bool `mapstructure:"insecure"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Datacenter string `mapstructure:"Datacenter"`
Datacenter string `mapstructure:"datacenter"`
VMName string `mapstructure:"vm_name"`
Folder string `mapstructure:"folder"`
@ -86,7 +86,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
if _, ok := builtins[artifact.BuilderId()]; !ok {
return nil, false, fmt.Errorf("Unknown artifact type, can't build template: %s", artifact.BuilderId())
return nil, false, fmt.Errorf("Unknown artifact type, can't build box: %s", artifact.BuilderId())
}
source := ""

View File

@ -18,7 +18,7 @@ func (s *stepChooseDatacenter) Run(state multistep.StateBag) multistep.StepActio
cli := state.Get("client").(*govmomi.Client)
finder := find.NewFinder(cli.Client, false)
datacenter, err := finder.DatacenterOrDefault(context.Background(), s.Datacenter)
dc, err := finder.DatacenterOrDefault(context.Background(), s.Datacenter)
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
@ -26,8 +26,8 @@ func (s *stepChooseDatacenter) Run(state multistep.StateBag) multistep.StepActio
return multistep.ActionHalt
}
finder.SetDatacenter(datacenter)
state.Put("Datacenter", datacenter.Name())
finder.SetDatacenter(dc)
state.Put("datacenter", dc.Name())
state.Put("finder", finder)
return multistep.ActionContinue
}

View File

@ -19,7 +19,7 @@ type stepCreateFolder struct {
func (s *stepCreateFolder) Run(state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
finder := state.Get("finder").(*find.Finder)
dc := state.Get("Datacenter").(string)
dc := state.Get("datacenter").(string)
if s.Folder != "" {
ui.Say("Creating or checking destination folders...")
@ -31,7 +31,8 @@ func (s *stepCreateFolder) Run(state multistep.StateBag) multistep.StepAction {
var err error
// We iterate over the path starting with full path
// If we don't find it, we save the folder name and continue with the previous path
// The iteration ends when we find an existing path
// The iteration ends when we find an existing path or if we don't find any we'll use
// the base path
for {
root, err = finder.Folder(context.Background(), filepath.ToSlash(filepath.Join(base, path)))
if err != nil {

View File

@ -16,11 +16,11 @@ type stepFetchVm struct {
func (s *stepFetchVm) Run(state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
f := state.Get("finder").(*find.Finder)
finder := state.Get("finder").(*find.Finder)
ui.Say("Fetching VM...")
if err := avoidOrphaned(f, s.VMName); err != nil {
if err := avoidOrphaned(finder, s.VMName); err != nil {
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
@ -31,21 +31,21 @@ func (s *stepFetchVm) Run(state multistep.StateBag) multistep.StepAction {
storage := path[:i]
vmx := path[i:]
ds, err := f.DatastoreOrDefault(context.Background(), storage)
ds, err := finder.DatastoreOrDefault(context.Background(), storage)
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
folder, err := f.DefaultFolder(context.Background())
folder, err := finder.DefaultFolder(context.Background())
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
pool, err := f.DefaultResourcePool(context.Background())
pool, err := finder.DefaultResourcePool(context.Background())
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
@ -65,7 +65,7 @@ func (s *stepFetchVm) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt
}
vm, err := f.VirtualMachine(context.Background(), s.VMName)
vm, err := finder.VirtualMachine(context.Background(), s.VMName)
if err != nil {
state.Put("error", err)
ui.Error(err.Error())

View File

@ -18,7 +18,7 @@ type stepMoveTemplate struct {
func (s *stepMoveTemplate) Run(state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
finder := state.Get("finder").(*find.Finder)
dc := state.Get("Datacenter").(string)
dc := state.Get("datacenter").(string)
vm := state.Get("vm").(*object.VirtualMachine)
if s.Folder != "" {

View File

@ -11,7 +11,7 @@ sidebar_current: 'docs-post-processors-vSphere-template'
Type: `vsphere-template`
The Packer vSphere template post-processor takes an artifact from the VMware-iso builder built on ESXi (i.e. remote)
The Packer vSphere template post-processor takes an artifact from the VMware-iso builder built on ESXi (i.e. remote) and
allows to mark a VM as a template and leaving it in a path of choice.
## Example