builder/vmware,virtualbox: checksum_type can be "none" [GH-471]

This commit is contained in:
Mitchell Hashimoto 2013-12-28 09:59:47 -07:00
parent e38c0424b9
commit 2b801a7b12
7 changed files with 65 additions and 10 deletions

View File

@ -64,7 +64,9 @@ IMPROVEMENTS:
* builder/virtualbox: Nice errors if Packer can't write to * builder/virtualbox: Nice errors if Packer can't write to
the output directory. the output directory.
* builder/virtualbox: ISO is ejected prior to export. * builder/virtualbox: ISO is ejected prior to export.
* builder/virtualbox: Checksum type can be "none" [GH-471]
* builder/vmware: Can now specify path to the Fusion application. [GH-677] * builder/vmware: Can now specify path to the Fusion application. [GH-677]
* builder/vmware: Checksum type can be "none" [GH-471]
* provisioner/puppet-masterless: Can now specify a `manifest_dir` to * provisioner/puppet-masterless: Can now specify a `manifest_dir` to
upload manifests to the remote machine for imports. [GH-655] upload manifests to the remote machine for imports. [GH-655]

View File

@ -187,10 +187,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs, errors.New("The iso_checksum_type must be specified.")) errs, errors.New("The iso_checksum_type must be specified."))
} else { } else {
b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType)
if h := common.HashForType(b.config.ISOChecksumType); h == nil { if b.config.ISOChecksumType != "none" {
errs = packer.MultiErrorAppend( if h := common.HashForType(b.config.ISOChecksumType); h == nil {
errs, errs = packer.MultiErrorAppend(
fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) errs,
fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType))
}
} }
} }
@ -236,6 +238,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
} }
// Warnings // Warnings
if b.config.ISOChecksumType == "none" {
warnings = append(warnings,
"A checksum type of 'none' was specified. Since ISO files are so big,\n"+
"a checksum is highly recommended.")
}
if b.config.ShutdownCommand == "" { if b.config.ShutdownCommand == "" {
warnings = append(warnings, warnings = append(warnings,
"A shutdown_command was not specified. Without a shutdown command, Packer\n"+ "A shutdown_command was not specified. Without a shutdown command, Packer\n"+

View File

@ -383,6 +383,21 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
if err == nil { if err == nil {
t.Fatal("should have error") t.Fatal("should have error")
} }
// Test none
config["iso_checksum_type"] = "none"
b = Builder{}
warns, err = b.Prepare(config)
if len(warns) == 0 {
t.Fatalf("bad: %#v", warns)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.ISOChecksumType != "none" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}
} }
func TestBuilderPrepare_ISOUrl(t *testing.T) { func TestBuilderPrepare_ISOUrl(t *testing.T) {

View File

@ -218,10 +218,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs, errors.New("The iso_checksum_type must be specified.")) errs, errors.New("The iso_checksum_type must be specified."))
} else { } else {
b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType)
if h := common.HashForType(b.config.ISOChecksumType); h == nil { if b.config.ISOChecksumType != "none" {
errs = packer.MultiErrorAppend( if h := common.HashForType(b.config.ISOChecksumType); h == nil {
errs, errs = packer.MultiErrorAppend(
fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) errs,
fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType))
}
} }
} }
@ -270,6 +272,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
} }
// Warnings // Warnings
if b.config.ISOChecksumType == "none" {
warnings = append(warnings,
"A checksum type of 'none' was specified. Since ISO files are so big,\n"+
"a checksum is highly recommended.")
}
if b.config.ShutdownCommand == "" { if b.config.ShutdownCommand == "" {
warnings = append(warnings, warnings = append(warnings,
"A shutdown_command was not specified. Without a shutdown command, Packer\n"+ "A shutdown_command was not specified. Without a shutdown command, Packer\n"+

View File

@ -98,7 +98,23 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
if err == nil { if err == nil {
t.Fatal("should have error") t.Fatal("should have error")
} }
// Test none
config["iso_checksum_type"] = "none"
b = Builder{}
warns, err = b.Prepare(config)
if len(warns) == 0 {
t.Fatalf("bad: %#v", warns)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.ISOChecksumType != "none" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}
} }
func TestBuilderPrepare_Defaults(t *testing.T) { func TestBuilderPrepare_Defaults(t *testing.T) {
var b Builder var b Builder
config := testConfig() config := testConfig()

View File

@ -54,7 +54,10 @@ Required:
checksum is specified with `iso_checksum_type`, documented below. checksum is specified with `iso_checksum_type`, documented below.
* `iso_checksum_type` (string) - The type of the checksum specified in * `iso_checksum_type` (string) - The type of the checksum specified in
`iso_checksum`. Valid values are "md5", "sha1", "sha256", or "sha512" currently. `iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or
"sha512" currently. While "none" will skip checksumming, this is not
recommended since ISO files are generally large and corruption does happen
from time to time.
* `iso_url` (string) - A URL to the ISO containing the installation image. * `iso_url` (string) - A URL to the ISO containing the installation image.
This URL can be either an HTTP URL or a file URL (or path to a file). This URL can be either an HTTP URL or a file URL (or path to a file).

View File

@ -55,7 +55,10 @@ Required:
checksum is specified with `iso_checksum_type`, documented below. checksum is specified with `iso_checksum_type`, documented below.
* `iso_checksum_type` (string) - The type of the checksum specified in * `iso_checksum_type` (string) - The type of the checksum specified in
`iso_checksum`. Valid values are "md5", "sha1", "sha256", or "sha512" currently. `iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or
"sha512" currently. While "none" will skip checksumming, this is not
recommended since ISO files are generally large and corruption does happen
from time to time.
* `iso_url` (string) - A URL to the ISO containing the installation image. * `iso_url` (string) - A URL to the ISO containing the installation image.
This URL can be either an HTTP URL or a file URL (or path to a file). This URL can be either an HTTP URL or a file URL (or path to a file).