From 0fe4d79bbf031ad539b90208eff7530e8d0dcac3 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 5 Dec 2018 15:57:45 -0800 Subject: [PATCH 1/3] add validation to prevent users from being confused about format functionality --- builder/vmware/iso/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/vmware/iso/config.go b/builder/vmware/iso/config.go index ec7d5822b..54ed11c28 100644 --- a/builder/vmware/iso/config.go +++ b/builder/vmware/iso/config.go @@ -167,7 +167,12 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } } - if c.Format == "" { + if c.Format != "" { + if c.RemoteType != "esx5" { + errs = packer.MultiErrorAppend(errs, + fmt.Errorf("format is only valid when RemoteType=esx5")) + } + } else { c.Format = "ovf" } From 0058422a5c2517e85deb75a5e0db62a4d765c971 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 5 Dec 2018 15:58:44 -0800 Subject: [PATCH 2/3] also for vmx --- builder/vmware/vmx/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index 94235e27e..3c950f285 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -98,7 +98,12 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { errs = packer.MultiErrorAppend(errs, err) } - if c.Format == "" { + if c.Format != "" { + if c.RemoteType != "esx5" { + errs = packer.MultiErrorAppend(errs, + fmt.Errorf("format is only valid when RemoteType=esx5")) + } + } else { c.Format = "ovf" } From dbfc1b5aff11dc4c001164276a713981bb75c49b Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 6 Dec 2018 09:36:16 -0800 Subject: [PATCH 3/3] fix tests --- builder/vmware/iso/builder_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index 1607f1cbb..195f8e381 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -171,6 +171,7 @@ func TestBuilderPrepare_RemoteType(t *testing.T) { // Good config["remote_type"] = "" + config["format"] = "" config["remote_host"] = "" config["remote_password"] = "" config["remote_private_key_file"] = "" @@ -245,6 +246,11 @@ func TestBuilderPrepare_Format(t *testing.T) { for _, format := range goodFormats { // Good config["format"] = format + config["remote_type"] = "esx5" + config["remote_host"] = "hosty.hostface" + config["remote_password"] = "password" + config["skip_validate_credentials"] = true + b = Builder{} warns, err = b.Prepare(config) if len(warns) > 0 {