From 3cc9f204acc289e9adbf70c3be087b5c2dd25b8a Mon Sep 17 00:00:00 2001 From: bugbuilder Date: Mon, 10 Jul 2017 20:52:48 -0400 Subject: [PATCH] Moving vsphere-tpl to vsphere-template, fixed root folder creation and updated docs --- command/plugin.go | 4 ++-- .../{vsphere-tpl => vsphere-template}/post-processor.go | 2 +- .../post_processor_test.go | 2 +- .../step_choose_datacenter.go | 2 +- .../step_create_folder.go | 8 +++++++- .../{vsphere-tpl => vsphere-template}/step_fetch_vm.go | 5 ++--- .../step_mark_as_template.go | 2 +- .../step_move_template.go | 2 +- .../source/docs/post-processors/vsphere-template.html.md | 8 ++++---- 9 files changed, 20 insertions(+), 15 deletions(-) rename post-processor/{vsphere-tpl => vsphere-template}/post-processor.go (99%) rename post-processor/{vsphere-tpl => vsphere-template}/post_processor_test.go (92%) rename post-processor/{vsphere-tpl => vsphere-template}/step_choose_datacenter.go (97%) rename post-processor/{vsphere-tpl => vsphere-template}/step_create_folder.go (87%) rename post-processor/{vsphere-tpl => vsphere-template}/step_fetch_vm.go (96%) rename post-processor/{vsphere-tpl => vsphere-template}/step_mark_as_template.go (96%) rename post-processor/{vsphere-tpl => vsphere-template}/step_move_template.go (98%) diff --git a/command/plugin.go b/command/plugin.go index 11d2a16af..e915ab521 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -54,7 +54,7 @@ import ( vagrantpostprocessor "github.com/hashicorp/packer/post-processor/vagrant" vagrantcloudpostprocessor "github.com/hashicorp/packer/post-processor/vagrant-cloud" vspherepostprocessor "github.com/hashicorp/packer/post-processor/vsphere" - vspheretplpostprocessor "github.com/hashicorp/packer/post-processor/vsphere-tpl" + vspheretemplatepostprocessor "github.com/hashicorp/packer/post-processor/vsphere-template" ansibleprovisioner "github.com/hashicorp/packer/provisioner/ansible" ansiblelocalprovisioner "github.com/hashicorp/packer/provisioner/ansible-local" chefclientprovisioner "github.com/hashicorp/packer/provisioner/chef-client" @@ -137,7 +137,7 @@ var PostProcessors = map[string]packer.PostProcessor{ "vagrant": new(vagrantpostprocessor.PostProcessor), "vagrant-cloud": new(vagrantcloudpostprocessor.PostProcessor), "vsphere": new(vspherepostprocessor.PostProcessor), - "vsphere-tpl": new(vspheretplpostprocessor.PostProcessor), + "vsphere-template": new(vspheretemplatepostprocessor.PostProcessor), } var pluginRegexp = regexp.MustCompile("packer-(builder|post-processor|provisioner)-(.+)") diff --git a/post-processor/vsphere-tpl/post-processor.go b/post-processor/vsphere-template/post-processor.go similarity index 99% rename from post-processor/vsphere-tpl/post-processor.go rename to post-processor/vsphere-template/post-processor.go index 1793036d0..52cdff1bd 100644 --- a/post-processor/vsphere-tpl/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" diff --git a/post-processor/vsphere-tpl/post_processor_test.go b/post-processor/vsphere-template/post_processor_test.go similarity index 92% rename from post-processor/vsphere-tpl/post_processor_test.go rename to post-processor/vsphere-template/post_processor_test.go index 70dee8e14..75b00ec38 100644 --- a/post-processor/vsphere-tpl/post_processor_test.go +++ b/post-processor/vsphere-template/post_processor_test.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "testing" diff --git a/post-processor/vsphere-tpl/step_choose_datacenter.go b/post-processor/vsphere-template/step_choose_datacenter.go similarity index 97% rename from post-processor/vsphere-tpl/step_choose_datacenter.go rename to post-processor/vsphere-template/step_choose_datacenter.go index a60c53ddc..05f366195 100644 --- a/post-processor/vsphere-tpl/step_choose_datacenter.go +++ b/post-processor/vsphere-template/step_choose_datacenter.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" diff --git a/post-processor/vsphere-tpl/step_create_folder.go b/post-processor/vsphere-template/step_create_folder.go similarity index 87% rename from post-processor/vsphere-tpl/step_create_folder.go rename to post-processor/vsphere-template/step_create_folder.go index e10161774..48ade578e 100644 --- a/post-processor/vsphere-tpl/step_create_folder.go +++ b/post-processor/vsphere-template/step_create_folder.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" @@ -41,6 +41,12 @@ func (s *StepCreateFolder) Run(state multistep.StateBag) multistep.StepAction { _, folder := filepath.Split(path) folders = append(folders, folder) if i := strings.LastIndex(path, "/"); i == 0 { + root, err = f.Folder(ctx, filepath.ToSlash(base)) + if err != nil { + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } break } else { path = path[:i] diff --git a/post-processor/vsphere-tpl/step_fetch_vm.go b/post-processor/vsphere-template/step_fetch_vm.go similarity index 96% rename from post-processor/vsphere-tpl/step_fetch_vm.go rename to post-processor/vsphere-template/step_fetch_vm.go index dbe05eeb0..5f1d2eaae 100644 --- a/post-processor/vsphere-tpl/step_fetch_vm.go +++ b/post-processor/vsphere-template/step_fetch_vm.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" @@ -60,8 +60,7 @@ func (s *StepFetchVm) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - err = task.Wait(ctx) - if err != nil { + if err = task.Wait(ctx); err != nil { state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/post-processor/vsphere-tpl/step_mark_as_template.go b/post-processor/vsphere-template/step_mark_as_template.go similarity index 96% rename from post-processor/vsphere-tpl/step_mark_as_template.go rename to post-processor/vsphere-template/step_mark_as_template.go index a3888849c..2f8834d2f 100644 --- a/post-processor/vsphere-tpl/step_mark_as_template.go +++ b/post-processor/vsphere-template/step_mark_as_template.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" diff --git a/post-processor/vsphere-tpl/step_move_template.go b/post-processor/vsphere-template/step_move_template.go similarity index 98% rename from post-processor/vsphere-tpl/step_move_template.go rename to post-processor/vsphere-template/step_move_template.go index 80625d78e..00f6ba711 100644 --- a/post-processor/vsphere-tpl/step_move_template.go +++ b/post-processor/vsphere-template/step_move_template.go @@ -1,4 +1,4 @@ -package vsphere_tpl +package vsphere_template import ( "context" diff --git a/website/source/docs/post-processors/vsphere-template.html.md b/website/source/docs/post-processors/vsphere-template.html.md index 38f39a90f..55f2e21da 100644 --- a/website/source/docs/post-processors/vsphere-template.html.md +++ b/website/source/docs/post-processors/vsphere-template.html.md @@ -1,6 +1,6 @@ --- description: | - The Packer vSphere Template post-processor takes an artifact from the VMware-iso builder -**only if remote ESXI is chosen**- + The Packer vSphere Template post-processor takes an artifact from the VMware-iso builder -**only if remote ESXI was chosen**- and allows to mark a VM as a template and leaving it in a path of choice. layout: docs page_title: 'vSphere Template - Post-Processors' @@ -9,9 +9,9 @@ sidebar_current: 'docs-post-processors-vSphere-template' # vSphere Template Post-Processor -Type: `vsphere-tpl` +Type: `vsphere-template` -The Packer vSphere template post-processor takes an artifact from the VMware-iso builder +The Packer vSphere template post-processor takes an artifact from the VMware-iso builder -**only if remote ESXI was chosen**- allows to mark a VM as a template and leaving it in a path of choice. ## Example @@ -20,7 +20,7 @@ An example is shown below, showing only the post-processor configuration: ``` json { - "type": "vsphere-tpl", + "type": "vsphere-template", "host": "vcenter.local", "username": "root", "password": "secret",