From cdcffecc2d40bd5ce2f2e367017ca74de3a6bfd7 Mon Sep 17 00:00:00 2001 From: Mark Peek Date: Tue, 20 Oct 2015 16:27:47 -0700 Subject: [PATCH 1/2] Refactor builder ISO options The ISO builders (parallels, qemu, virtualbox, and vmware) had too much common code which needed to be maintained separately. This change moves that code to a common ISO configuration. --- builder/parallels/iso/builder.go | 63 ++-------- builder/parallels/iso/builder_test.go | 157 ----------------------- builder/qemu/builder.go | 67 ++-------- builder/qemu/builder_test.go | 145 +--------------------- builder/virtualbox/iso/builder.go | 63 ++-------- builder/virtualbox/iso/builder_test.go | 157 ----------------------- builder/vmware/iso/builder.go | 63 ++-------- builder/vmware/iso/builder_test.go | 156 ----------------------- common/iso_config.go | 73 +++++++++++ common/iso_config_test.go | 165 +++++++++++++++++++++++++ 10 files changed, 277 insertions(+), 832 deletions(-) create mode 100644 common/iso_config.go create mode 100644 common/iso_config_test.go diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 5e8b178fc..4dda28cbe 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "log" - "strings" "github.com/mitchellh/multistep" parallelscommon "github.com/mitchellh/packer/builder/parallels/common" @@ -24,6 +23,7 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` + common.ISOConfig `mapstructure:",squash"` parallelscommon.FloppyConfig `mapstructure:",squash"` parallelscommon.OutputConfig `mapstructure:",squash"` parallelscommon.PrlctlConfig `mapstructure:",squash"` @@ -42,14 +42,8 @@ type Config struct { HTTPDir string `mapstructure:"http_directory"` HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` - ISOChecksum string `mapstructure:"iso_checksum"` - ISOChecksumType string `mapstructure:"iso_checksum_type"` - ISOUrls []string `mapstructure:"iso_urls"` SkipCompaction bool `mapstructure:"skip_compaction"` VMName string `mapstructure:"vm_name"` - TargetPath string `mapstructure:"iso_target_path"` - - RawSingleISOUrl string `mapstructure:"iso_url"` // Deprecated parameters GuestOSDistribution string `mapstructure:"guest_os_distribution"` @@ -77,6 +71,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { // Accumulate any errors and warnings var errs *packer.MultiError + warnings := make([]string, 0) + + isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) + warnings = append(warnings, isoWarnings...) + errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend( errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) @@ -87,7 +87,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...) - warnings := make([]string, 0) if b.config.DiskSize == 0 { b.config.DiskSize = 40000 @@ -138,52 +137,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs, errors.New("http_port_min must be less than http_port_max")) } - if b.config.ISOChecksumType == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("The iso_checksum_type must be specified.")) - } else { - b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) - if b.config.ISOChecksumType != "none" { - if b.config.ISOChecksum == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("Due to large file sizes, an iso_checksum is required")) - } else { - b.config.ISOChecksum = strings.ToLower(b.config.ISOChecksum) - } - - if h := common.HashForType(b.config.ISOChecksumType); h == nil { - errs = packer.MultiErrorAppend( - errs, - fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) - } - } - } - - if b.config.RawSingleISOUrl == "" && len(b.config.ISOUrls) == 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("One of iso_url or iso_urls must be specified.")) - } else if b.config.RawSingleISOUrl != "" && len(b.config.ISOUrls) > 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("Only one of iso_url or iso_urls may be specified.")) - } else if b.config.RawSingleISOUrl != "" { - b.config.ISOUrls = []string{b.config.RawSingleISOUrl} - } - - for i, url := range b.config.ISOUrls { - b.config.ISOUrls[i], err = common.DownloadableURL(url) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed to parse iso_url %d: %s", i+1, err)) - } - } - // 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 == "" { warnings = append(warnings, "A shutdown_command was not specified. Without a shutdown command, Packer\n"+ @@ -219,9 +173,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Checksum: b.config.ISOChecksum, ChecksumType: b.config.ISOChecksumType, Description: "ISO", + Extension: "iso", ResultKey: "iso_path", - Url: b.config.ISOUrls, TargetPath: b.config.TargetPath, + Url: b.config.ISOUrls, }, ¶llelscommon.StepOutputDir{ Force: b.config.PackerForce, diff --git a/builder/parallels/iso/builder_test.go b/builder/parallels/iso/builder_test.go index b7d4cac50..ff0af5582 100644 --- a/builder/parallels/iso/builder_test.go +++ b/builder/parallels/iso/builder_test.go @@ -2,7 +2,6 @@ package iso import ( "github.com/mitchellh/packer/packer" - "reflect" "testing" ) @@ -193,162 +192,6 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) { } } -func TestBuilderPrepare_ISOChecksum(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum"] = "FOo" - 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.ISOChecksum != "foo" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksum) - } -} - -func TestBuilderPrepare_ISOChecksumType(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum_type"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum_type"] = "mD5" - 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 != "md5" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType) - } - - // Test unknown - config["iso_checksum_type"] = "fake" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - 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) { - var b Builder - config := testConfig() - delete(config, "iso_url") - delete(config, "iso_urls") - - // Test both epty - config["iso_url"] = "" - b = Builder{} - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test iso_url set - config["iso_url"] = "http://www.packer.io" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected := []string{"http://www.packer.io"} - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } - - // Test both set - config["iso_url"] = "http://www.packer.io" - config["iso_urls"] = []string{"http://www.packer.io"} - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test just iso_urls set - delete(config, "iso_url") - config["iso_urls"] = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } -} - func TestBuilderPrepare_ParallelsToolsHostPath(t *testing.T) { var b Builder config := testConfig() diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 585250534..568e8c80d 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -8,7 +8,6 @@ import ( "os/exec" "path/filepath" "runtime" - "strings" "time" "github.com/mitchellh/multistep" @@ -22,10 +21,10 @@ import ( const BuilderId = "transcend.qemu" var accels = map[string]struct{}{ - "none": struct{}{}, - "kvm": struct{}{}, - "tcg": struct{}{}, - "xen": struct{}{}, + "none": {}, + "kvm": {}, + "tcg": {}, + "xen": {}, } var netDevice = map[string]bool{ @@ -80,6 +79,7 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` + common.ISOConfig `mapstructure:",squash"` Comm communicator.Config `mapstructure:",squash"` Accelerator string `mapstructure:"accelerator"` @@ -95,9 +95,6 @@ type Config struct { HTTPDir string `mapstructure:"http_directory"` HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` - ISOChecksum string `mapstructure:"iso_checksum"` - ISOChecksumType string `mapstructure:"iso_checksum_type"` - ISOUrls []string `mapstructure:"iso_urls"` MachineType string `mapstructure:"machine_type"` NetDevice string `mapstructure:"net_device"` OutputDir string `mapstructure:"output_directory"` @@ -106,7 +103,6 @@ type Config struct { ShutdownCommand string `mapstructure:"shutdown_command"` SSHHostPortMin uint `mapstructure:"ssh_host_port_min"` SSHHostPortMax uint `mapstructure:"ssh_host_port_max"` - TargetPath string `mapstructure:"iso_target_path"` VNCPortMin uint `mapstructure:"vnc_port_min"` VNCPortMax uint `mapstructure:"vnc_port_max"` VMName string `mapstructure:"vm_name"` @@ -120,7 +116,6 @@ type Config struct { RunOnce bool `mapstructure:"run_once"` RawBootWait string `mapstructure:"boot_wait"` - RawSingleISOUrl string `mapstructure:"iso_url"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"` bootWait time.Duration `` @@ -234,6 +229,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { var errs *packer.MultiError warnings := make([]string, 0) + isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) + warnings = append(warnings, isoWarnings...) + errs = packer.MultiErrorAppend(errs, isoErrs...) + if es := b.config.Comm.Prepare(&b.config.ctx); len(es) > 0 { errs = packer.MultiErrorAppend(errs, es...) } @@ -273,45 +272,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs, errors.New("http_port_min must be less than http_port_max")) } - if b.config.ISOChecksumType == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("The iso_checksum_type must be specified.")) - } else { - b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) - if b.config.ISOChecksumType != "none" { - if b.config.ISOChecksum == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("Due to large file sizes, an iso_checksum is required")) - } else { - b.config.ISOChecksum = strings.ToLower(b.config.ISOChecksum) - } - - if h := common.HashForType(b.config.ISOChecksumType); h == nil { - errs = packer.MultiErrorAppend( - errs, - fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) - } - } - } - - if b.config.RawSingleISOUrl == "" && len(b.config.ISOUrls) == 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("One of iso_url or iso_urls must be specified.")) - } else if b.config.RawSingleISOUrl != "" && len(b.config.ISOUrls) > 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("Only one of iso_url or iso_urls may be specified.")) - } else if b.config.RawSingleISOUrl != "" { - b.config.ISOUrls = []string{b.config.RawSingleISOUrl} - } - - for i, url := range b.config.ISOUrls { - b.config.ISOUrls[i], err = common.DownloadableURL(url) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed to parse iso_url %d: %s", i+1, err)) - } - } - if !b.config.PackerForce { if _, err := os.Stat(b.config.OutputDir); err == nil { errs = packer.MultiErrorAppend( @@ -350,12 +310,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.QemuArgs = make([][]string, 0) } - 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 errs != nil && len(errs.Errors) > 0 { return warnings, errs } @@ -384,9 +338,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Checksum: b.config.ISOChecksum, ChecksumType: b.config.ISOChecksumType, Description: "ISO", + Extension: "iso", ResultKey: "iso_path", - Url: b.config.ISOUrls, TargetPath: b.config.TargetPath, + Url: b.config.ISOUrls, }, new(stepPrepareOutputDir), &common.StepCreateFloppy{ diff --git a/builder/qemu/builder_test.go b/builder/qemu/builder_test.go index 84d1d40c3..69442c01f 100644 --- a/builder/qemu/builder_test.go +++ b/builder/qemu/builder_test.go @@ -255,147 +255,6 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) { } } -func TestBuilderPrepare_ISOChecksum(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum"] = "FOo" - 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.ISOChecksum != "foo" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksum) - } -} - -func TestBuilderPrepare_ISOChecksumType(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum_type"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum_type"] = "mD5" - 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 != "md5" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType) - } - - // Test unknown - config["iso_checksum_type"] = "fake" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } -} - -func TestBuilderPrepare_ISOUrl(t *testing.T) { - var b Builder - config := testConfig() - delete(config, "iso_url") - delete(config, "iso_urls") - - // Test both epty - config["iso_url"] = "" - b = Builder{} - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test iso_url set - config["iso_url"] = "http://www.packer.io" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected := []string{"http://www.packer.io"} - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } - - // Test both set - config["iso_url"] = "http://www.packer.io" - config["iso_urls"] = []string{"http://www.packer.io"} - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test just iso_urls set - delete(config, "iso_url") - config["iso_urls"] = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } -} - func TestBuilderPrepare_OutputDir(t *testing.T) { var b Builder config := testConfig() @@ -638,7 +497,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) { // Test with a good one config["qemuargs"] = [][]interface{}{ - []interface{}{"foo", "bar", "baz"}, + {"foo", "bar", "baz"}, } b = Builder{} @@ -651,7 +510,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) { } expected := [][]string{ - []string{"foo", "bar", "baz"}, + {"foo", "bar", "baz"}, } if !reflect.DeepEqual(b.config.QemuArgs, expected) { diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index d70ee2a73..587d2f28e 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -24,6 +24,7 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` + common.ISOConfig `mapstructure:",squash"` vboxcommon.ExportConfig `mapstructure:",squash"` vboxcommon.ExportOpts `mapstructure:",squash"` vboxcommon.FloppyConfig `mapstructure:",squash"` @@ -43,15 +44,9 @@ type Config struct { GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"` GuestOSType string `mapstructure:"guest_os_type"` HardDriveInterface string `mapstructure:"hard_drive_interface"` - ISOChecksum string `mapstructure:"iso_checksum"` - ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOInterface string `mapstructure:"iso_interface"` - ISOUrls []string `mapstructure:"iso_urls"` - TargetPath string `mapstructure:"iso_target_path"` VMName string `mapstructure:"vm_name"` - RawSingleISOUrl string `mapstructure:"iso_url"` - ctx interpolate.Context } @@ -75,6 +70,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { // Accumulate any errors and warnings var errs *packer.MultiError + warnings := make([]string, 0) + + isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) + warnings = append(warnings, isoWarnings...) + errs = packer.MultiErrorAppend(errs, isoErrs...) + errs = packer.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.ExportOpts.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...) @@ -86,7 +87,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, b.config.VBoxManageConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.VBoxManagePostConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.VBoxVersionConfig.Prepare(&b.config.ctx)...) - warnings := make([]string, 0) if b.config.DiskSize == 0 { b.config.DiskSize = 40000 @@ -122,50 +122,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs, errors.New("hard_drive_interface can only be ide, sata, or scsi")) } - if b.config.ISOChecksumType == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("The iso_checksum_type must be specified.")) - } else { - b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) - if b.config.ISOChecksumType != "none" { - if b.config.ISOChecksum == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("Due to large file sizes, an iso_checksum is required")) - } else { - b.config.ISOChecksum = strings.ToLower(b.config.ISOChecksum) - } - - if h := common.HashForType(b.config.ISOChecksumType); h == nil { - errs = packer.MultiErrorAppend( - errs, - fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) - } - } - } - if b.config.ISOInterface != "ide" && b.config.ISOInterface != "sata" { errs = packer.MultiErrorAppend( errs, errors.New("iso_interface can only be ide or sata")) } - if b.config.RawSingleISOUrl == "" && len(b.config.ISOUrls) == 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("One of iso_url or iso_urls must be specified.")) - } else if b.config.RawSingleISOUrl != "" && len(b.config.ISOUrls) > 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("Only one of iso_url or iso_urls may be specified.")) - } else if b.config.RawSingleISOUrl != "" { - b.config.ISOUrls = []string{b.config.RawSingleISOUrl} - } - - for i, url := range b.config.ISOUrls { - b.config.ISOUrls[i], err = common.DownloadableURL(url) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed to parse iso_url %d: %s", i+1, err)) - } - } - validMode := false validModes := []string{ vboxcommon.GuestAdditionsModeDisable, @@ -190,12 +151,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } // 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 == "" { warnings = append(warnings, "A shutdown_command was not specified. Without a shutdown command, Packer\n"+ @@ -227,10 +182,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Checksum: b.config.ISOChecksum, ChecksumType: b.config.ISOChecksumType, Description: "ISO", - ResultKey: "iso_path", - Url: b.config.ISOUrls, Extension: "iso", + ResultKey: "iso_path", TargetPath: b.config.TargetPath, + Url: b.config.ISOUrls, }, &vboxcommon.StepOutputDir{ Force: b.config.PackerForce, diff --git a/builder/virtualbox/iso/builder_test.go b/builder/virtualbox/iso/builder_test.go index 714587f24..eb2d2fb75 100644 --- a/builder/virtualbox/iso/builder_test.go +++ b/builder/virtualbox/iso/builder_test.go @@ -3,7 +3,6 @@ package iso import ( "github.com/mitchellh/packer/builder/virtualbox/common" "github.com/mitchellh/packer/packer" - "reflect" "testing" ) @@ -315,92 +314,6 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) { } } -func TestBuilderPrepare_ISOChecksum(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum"] = "FOo" - 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.ISOChecksum != "foo" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksum) - } -} - -func TestBuilderPrepare_ISOChecksumType(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum_type"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum_type"] = "mD5" - 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 != "md5" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType) - } - - // Test unknown - config["iso_checksum_type"] = "fake" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - 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_ISOInterface(t *testing.T) { var b Builder config := testConfig() @@ -441,73 +354,3 @@ func TestBuilderPrepare_ISOInterface(t *testing.T) { t.Fatalf("should not have error: %s", err) } } - -func TestBuilderPrepare_ISOUrl(t *testing.T) { - var b Builder - config := testConfig() - delete(config, "iso_url") - delete(config, "iso_urls") - - // Test both epty - config["iso_url"] = "" - b = Builder{} - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test iso_url set - config["iso_url"] = "http://www.packer.io" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected := []string{"http://www.packer.io"} - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } - - // Test both set - config["iso_url"] = "http://www.packer.io" - config["iso_urls"] = []string{"http://www.packer.io"} - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test just iso_urls set - delete(config, "iso_url") - config["iso_urls"] = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } -} diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index bac3dbdff..c2c8bc470 100755 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "log" "os" - "strings" "time" "github.com/mitchellh/multistep" @@ -27,6 +26,7 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` + common.ISOConfig `mapstructure:",squash"` vmwcommon.DriverConfig `mapstructure:",squash"` vmwcommon.OutputConfig `mapstructure:",squash"` vmwcommon.RunConfig `mapstructure:",squash"` @@ -41,14 +41,10 @@ type Config struct { DiskTypeId string `mapstructure:"disk_type_id"` FloppyFiles []string `mapstructure:"floppy_files"` GuestOSType string `mapstructure:"guest_os_type"` - ISOChecksum string `mapstructure:"iso_checksum"` - ISOChecksumType string `mapstructure:"iso_checksum_type"` - ISOUrls []string `mapstructure:"iso_urls"` Version string `mapstructure:"version"` VMName string `mapstructure:"vm_name"` BootCommand []string `mapstructure:"boot_command"` SkipCompaction bool `mapstructure:"skip_compaction"` - TargetPath string `mapstructure:"iso_target_path"` VMXTemplatePath string `mapstructure:"vmx_template_path"` VMXDiskTemplatePath string `mapstructure:"vmx_disk_template_path"` @@ -61,8 +57,6 @@ type Config struct { RemoteUser string `mapstructure:"remote_username"` RemotePassword string `mapstructure:"remote_password"` - RawSingleISOUrl string `mapstructure:"iso_url"` - ctx interpolate.Context } @@ -83,6 +77,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { // Accumulate any errors and warnings var errs *packer.MultiError + warnings := make([]string, 0) + + isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx) + warnings = append(warnings, isoWarnings...) + errs = packer.MultiErrorAppend(errs, isoErrs...) errs = packer.MultiErrorAppend(errs, b.config.DriverConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...) @@ -91,7 +90,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.VMXConfig.Prepare(&b.config.ctx)...) - warnings := make([]string, 0) if b.config.DiskName == "" { b.config.DiskName = "disk" @@ -146,45 +144,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.RemotePort = 22 } - if b.config.ISOChecksumType == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("The iso_checksum_type must be specified.")) - } else { - b.config.ISOChecksumType = strings.ToLower(b.config.ISOChecksumType) - if b.config.ISOChecksumType != "none" { - if b.config.ISOChecksum == "" { - errs = packer.MultiErrorAppend( - errs, errors.New("Due to large file sizes, an iso_checksum is required")) - } else { - b.config.ISOChecksum = strings.ToLower(b.config.ISOChecksum) - } - - if h := common.HashForType(b.config.ISOChecksumType); h == nil { - errs = packer.MultiErrorAppend( - errs, - fmt.Errorf("Unsupported checksum type: %s", b.config.ISOChecksumType)) - } - } - } - - if b.config.RawSingleISOUrl == "" && len(b.config.ISOUrls) == 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("One of iso_url or iso_urls must be specified.")) - } else if b.config.RawSingleISOUrl != "" && len(b.config.ISOUrls) > 0 { - errs = packer.MultiErrorAppend( - errs, errors.New("Only one of iso_url or iso_urls may be specified.")) - } else if b.config.RawSingleISOUrl != "" { - b.config.ISOUrls = []string{b.config.RawSingleISOUrl} - } - - for i, url := range b.config.ISOUrls { - b.config.ISOUrls[i], err = common.DownloadableURL(url) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Failed to parse iso_url %d: %s", i+1, err)) - } - } - if b.config.VMXTemplatePath != "" { if err := b.validateVMXTemplatePath(); err != nil { errs = packer.MultiErrorAppend( @@ -202,12 +161,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } // 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 == "" { warnings = append(warnings, "A shutdown_command was not specified. Without a shutdown command, Packer\n"+ @@ -255,10 +208,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Checksum: b.config.ISOChecksum, ChecksumType: b.config.ISOChecksumType, Description: "ISO", - ResultKey: "iso_path", - Url: b.config.ISOUrls, Extension: "iso", + ResultKey: "iso_path", TargetPath: b.config.TargetPath, + Url: b.config.ISOUrls, }, &vmwcommon.StepOutputDir{ Force: b.config.PackerForce, diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index 13a9622f7..2be304a54 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -29,92 +29,6 @@ func TestBuilder_ImplementsBuilder(t *testing.T) { } } -func TestBuilderPrepare_ISOChecksum(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum"] = "FOo" - 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.ISOChecksum != "foo" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksum) - } -} - -func TestBuilderPrepare_ISOChecksumType(t *testing.T) { - var b Builder - config := testConfig() - - // Test bad - config["iso_checksum_type"] = "" - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test good - config["iso_checksum_type"] = "mD5" - 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 != "md5" { - t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType) - } - - // Test unknown - config["iso_checksum_type"] = "fake" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - 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) { var b Builder config := testConfig() @@ -262,76 +176,6 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) { } } -func TestBuilderPrepare_ISOUrl(t *testing.T) { - var b Builder - config := testConfig() - delete(config, "iso_url") - delete(config, "iso_urls") - - // Test both epty - config["iso_url"] = "" - b = Builder{} - warns, err := b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test iso_url set - config["iso_url"] = "http://www.packer.io" - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected := []string{"http://www.packer.io"} - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } - - // Test both set - config["iso_url"] = "http://www.packer.io" - config["iso_urls"] = []string{"http://www.packer.io"} - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should have error") - } - - // Test just iso_urls set - delete(config, "iso_url") - config["iso_urls"] = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - - b = Builder{} - warns, err = b.Prepare(config) - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Errorf("should not have error: %s", err) - } - - expected = []string{ - "http://www.packer.io", - "http://www.hashicorp.com", - } - if !reflect.DeepEqual(b.config.ISOUrls, expected) { - t.Fatalf("bad: %#v", b.config.ISOUrls) - } -} - func TestBuilderPrepare_OutputDir(t *testing.T) { var b Builder config := testConfig() diff --git a/common/iso_config.go b/common/iso_config.go new file mode 100644 index 000000000..6e3cd1f61 --- /dev/null +++ b/common/iso_config.go @@ -0,0 +1,73 @@ +package common + +import ( + "errors" + "fmt" + "strings" + + "github.com/mitchellh/packer/template/interpolate" +) + +// ISOConfig contains configuration for downloading ISO images. +type ISOConfig struct { + ISOChecksum string `mapstructure:"iso_checksum"` + ISOChecksumType string `mapstructure:"iso_checksum_type"` + ISOUrls []string `mapstructure:"iso_urls"` + TargetPath string `mapstructure:"iso_target_path"` + RawSingleISOUrl string `mapstructure:"iso_url"` +} + +func (c *ISOConfig) Prepare(ctx *interpolate.Context) ([]string, []error) { + // Validation + var errs []error + var err error + var warnings []string + + if c.ISOChecksumType == "" { + errs = append( + errs, errors.New("The iso_checksum_type must be specified.")) + } else { + c.ISOChecksumType = strings.ToLower(c.ISOChecksumType) + if c.ISOChecksumType != "none" { + if c.ISOChecksum == "" { + errs = append( + errs, errors.New("Due to large file sizes, an iso_checksum is required")) + } else { + c.ISOChecksum = strings.ToLower(c.ISOChecksum) + } + + if h := HashForType(c.ISOChecksumType); h == nil { + errs = append( + errs, + fmt.Errorf("Unsupported checksum type: %s", c.ISOChecksumType)) + } + } + } + + if c.RawSingleISOUrl == "" && len(c.ISOUrls) == 0 { + errs = append( + errs, errors.New("One of iso_url or iso_urls must be specified.")) + } else if c.RawSingleISOUrl != "" && len(c.ISOUrls) > 0 { + errs = append( + errs, errors.New("Only one of iso_url or iso_urls may be specified.")) + } else if c.RawSingleISOUrl != "" { + c.ISOUrls = []string{c.RawSingleISOUrl} + } + + for i, url := range c.ISOUrls { + c.ISOUrls[i], err = DownloadableURL(url) + if err != nil { + errs = append( + errs, fmt.Errorf("Failed to parse iso_url %d: %s", i+1, err)) + } + } + + // Warnings + if c.ISOChecksumType == "none" { + warnings = append(warnings, + "A checksum type of 'none' was specified. Since ISO files are so big,\n"+ + "a checksum is highly recommended.") + } + + return warnings, errs +} diff --git a/common/iso_config_test.go b/common/iso_config_test.go new file mode 100644 index 000000000..01e801ff4 --- /dev/null +++ b/common/iso_config_test.go @@ -0,0 +1,165 @@ +package common + +import ( + "reflect" + "testing" +) + +func testISOConfig() ISOConfig { + return ISOConfig{ + ISOChecksum: "foo", + ISOChecksumType: "md5", + RawSingleISOUrl: "http://www.packer.io", + } +} + +func TestISOConfigPrepare_ISOChecksum(t *testing.T) { + i := testISOConfig() + + // Test bad + i.ISOChecksum = "" + warns, err := i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err == nil { + t.Fatal("should have error") + } + + // Test good + i = testISOConfig() + i.ISOChecksum = "FOo" + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err != nil { + t.Fatalf("should not have error: %s", err) + } + + if i.ISOChecksum != "foo" { + t.Fatalf("should've lowercased: %s", i.ISOChecksum) + } +} + +func TestISOConfigPrepare_ISOChecksumType(t *testing.T) { + i := testISOConfig() + + // Test bad + i.ISOChecksumType = "" + warns, err := i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err == nil { + t.Fatal("should have error") + } + + // Test good + i = testISOConfig() + i.ISOChecksumType = "mD5" + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err != nil { + t.Fatalf("should not have error: %s", err) + } + + if i.ISOChecksumType != "md5" { + t.Fatalf("should've lowercased: %s", i.ISOChecksumType) + } + + // Test unknown + i = testISOConfig() + i.ISOChecksumType = "fake" + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err == nil { + t.Fatal("should have error") + } + + // Test none + i = testISOConfig() + i.ISOChecksumType = "none" + warns, err = i.Prepare(nil) + if len(warns) == 0 { + t.Fatalf("bad: %#v", warns) + } + if err != nil { + t.Fatalf("should not have error: %s", err) + } + + if i.ISOChecksumType != "none" { + t.Fatalf("should've lowercased: %s", i.ISOChecksumType) + } +} + +func TestISOConfigPrepare_ISOUrl(t *testing.T) { + i := testISOConfig() + + // Test both empty + i.RawSingleISOUrl = "" + i.ISOUrls = []string{} + warns, err := i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err == nil { + t.Fatal("should have error") + } + + // Test iso_url set + i = testISOConfig() + i.RawSingleISOUrl = "http://www.packer.io" + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err != nil { + t.Errorf("should not have error: %s", err) + } + + expected := []string{"http://www.packer.io"} + if !reflect.DeepEqual(i.ISOUrls, expected) { + t.Fatalf("bad: %#v", i.ISOUrls) + } + + // Test both set + i = testISOConfig() + i.RawSingleISOUrl = "http://www.packer.io" + i.ISOUrls = []string{"http://www.packer.io"} + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err == nil { + t.Fatal("should have error") + } + + // Test just iso_urls set + i = testISOConfig() + i.RawSingleISOUrl = "" + i.ISOUrls = []string{ + "http://www.packer.io", + "http://www.hashicorp.com", + } + + warns, err = i.Prepare(nil) + if len(warns) > 0 { + t.Fatalf("bad: %#v", warns) + } + if err != nil { + t.Errorf("should not have error: %s", err) + } + + expected = []string{ + "http://www.packer.io", + "http://www.hashicorp.com", + } + if !reflect.DeepEqual(i.ISOUrls, expected) { + t.Fatalf("bad: %#v", i.ISOUrls) + } +} From c3d77dc5a14819d33962327bffa6d5446410612b Mon Sep 17 00:00:00 2001 From: Mark Peek Date: Mon, 26 Oct 2015 17:39:48 -0700 Subject: [PATCH 2/2] Fix unintended BC issues in ISO option refactoring --- builder/qemu/builder.go | 8 ++++---- builder/qemu/builder_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 568e8c80d..eb38ba0c7 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -21,10 +21,10 @@ import ( const BuilderId = "transcend.qemu" var accels = map[string]struct{}{ - "none": {}, - "kvm": {}, - "tcg": {}, - "xen": {}, + "none": struct{}{}, + "kvm": struct{}{}, + "tcg": struct{}{}, + "xen": struct{}{}, } var netDevice = map[string]bool{ diff --git a/builder/qemu/builder_test.go b/builder/qemu/builder_test.go index 69442c01f..d2a1d1eba 100644 --- a/builder/qemu/builder_test.go +++ b/builder/qemu/builder_test.go @@ -497,7 +497,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) { // Test with a good one config["qemuargs"] = [][]interface{}{ - {"foo", "bar", "baz"}, + []interface{}{"foo", "bar", "baz"}, } b = Builder{} @@ -510,7 +510,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) { } expected := [][]string{ - {"foo", "bar", "baz"}, + []string{"foo", "bar", "baz"}, } if !reflect.DeepEqual(b.config.QemuArgs, expected) {