builder/vmware: require an MD5 for ISO
This commit is contained in:
parent
896c727097
commit
4b46181f69
|
@ -26,6 +26,7 @@ type Builder struct {
|
|||
type config struct {
|
||||
DiskName string `mapstructure:"vmdk_name"`
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
ISOMD5 string `mapstructure:"iso_md5"`
|
||||
ISOUrl string `mapstructure:"iso_url"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
OutputDir string `mapstructure:"output_directory"`
|
||||
|
@ -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"))
|
||||
}
|
||||
|
||||
if b.config.ISOMD5 == "" {
|
||||
errs = append(errs, errors.New("Due to large file sizes, an iso_md5 is required"))
|
||||
}
|
||||
|
||||
if b.config.ISOUrl == "" {
|
||||
errs = append(errs, errors.New("An iso_url must be specified."))
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
func testConfig() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"iso_md5": "foo",
|
||||
"iso_url": "http://www.packer.io",
|
||||
"ssh_username": "foo",
|
||||
}
|
||||
|
@ -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) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
|
Loading…
Reference in New Issue