Commit 4b46181f authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: require an MD5 for ISO

parent 896c7270
...@@ -26,6 +26,7 @@ type Builder struct { ...@@ -26,6 +26,7 @@ type Builder struct {
type config struct { type config struct {
DiskName string `mapstructure:"vmdk_name"` DiskName string `mapstructure:"vmdk_name"`
GuestOSType string `mapstructure:"guest_os_type"` GuestOSType string `mapstructure:"guest_os_type"`
ISOMD5 string `mapstructure:"iso_md5"`
ISOUrl string `mapstructure:"iso_url"` ISOUrl string `mapstructure:"iso_url"`
VMName string `mapstructure:"vm_name"` VMName string `mapstructure:"vm_name"`
OutputDir string `mapstructure:"output_directory"` OutputDir string `mapstructure:"output_directory"`
...@@ -93,6 +94,10 @@ func (b *Builder) Prepare(raw interface{}) (err error) { ...@@ -93,6 +94,10 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
errs = append(errs, errors.New("http_port_min must be less than http_port_max")) errs = append(errs, errors.New("http_port_min must be less than http_port_max"))
} }
if b.config.ISOMD5 == "" {
errs = append(errs, errors.New("Due to large file sizes, an iso_md5 is required"))
}
if b.config.ISOUrl == "" { if b.config.ISOUrl == "" {
errs = append(errs, errors.New("An iso_url must be specified.")) errs = append(errs, errors.New("An iso_url must be specified."))
} else { } else {
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {
return map[string]interface{}{ return map[string]interface{}{
"iso_md5": "foo",
"iso_url": "http://www.packer.io", "iso_url": "http://www.packer.io",
"ssh_username": "foo", "ssh_username": "foo",
} }
...@@ -95,6 +96,25 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) { ...@@ -95,6 +96,25 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
} }
} }
func TestBuilderPrepare_ISOMD5(t *testing.T) {
var b Builder
config := testConfig()
// Test bad
config["iso_md5"] = ""
err := b.Prepare(config)
if err == nil {
t.Fatal("should have error")
}
// Test good
config["iso_md5"] = "foo"
err = b.Prepare(config)
if err != nil {
t.Fatalf("should not have error: %s", err)
}
}
func TestBuilderPrepare_ISOUrl(t *testing.T) { func TestBuilderPrepare_ISOUrl(t *testing.T) {
var b Builder var b Builder
config := testConfig() config := testConfig()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment