From 3b413d2e5e6f613b4a476a827591ec6a011fee99 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 12 Nov 2018 13:24:03 -0800 Subject: [PATCH] fix rebase conflicts --- builder/vmware/iso/builder.go | 67 ----------------------------------- builder/vmware/iso/config.go | 4 +-- 2 files changed, 2 insertions(+), 69 deletions(-) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index bbc09e561..dc49f157d 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" "log" - "os" - "strings" "time" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" @@ -28,18 +26,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } b.config = *c - if b.config.VMXTemplatePath != "" { - if err := b.validateVMXTemplatePath(); err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("vmx_template_path is invalid: %s", err)) - } - - } else { - warn := b.checkForVMXTemplateAndVMXDataCollisions() - if warn != "" { - warnings = append(warnings, warn) - } - } return warnings, nil } @@ -221,56 +207,3 @@ func (b *Builder) Cancel() { b.runner.Cancel() } } - -// Validate the vmx_data option against the default vmx template to warn -// user if anything is being overridden. -func (b *Builder) checkForVMXTemplateAndVMXDataCollisions() string { - if b.config.VMXTemplatePath != "" { - return "" - } - - var overridden []string - tplLines := strings.Split(DefaultVMXTemplate, "\n") - tplLines = append(tplLines, - fmt.Sprintf("%s0:0.present", strings.ToLower(b.config.DiskAdapterType)), - fmt.Sprintf("%s0:0.fileName", strings.ToLower(b.config.DiskAdapterType)), - fmt.Sprintf("%s0:0.deviceType", strings.ToLower(b.config.DiskAdapterType)), - fmt.Sprintf("%s0:1.present", strings.ToLower(b.config.DiskAdapterType)), - fmt.Sprintf("%s0:1.fileName", strings.ToLower(b.config.DiskAdapterType)), - fmt.Sprintf("%s0:1.deviceType", strings.ToLower(b.config.DiskAdapterType)), - ) - - for _, line := range tplLines { - if strings.Contains(line, `{{`) { - key := line[:strings.Index(line, " =")] - if _, ok := b.config.VMXData[key]; ok { - overridden = append(overridden, key) - } - } - } - - if len(overridden) > 0 { - warnings := fmt.Sprintf("Your vmx data contains the following "+ - "variable(s), which Packer normally sets when it generates its "+ - "own default vmx template. This may cause your build to fail or "+ - "behave unpredictably: %s", strings.Join(overridden, ", ")) - return warnings - } - return "" -} - -// Make sure custom vmx template exists and that data can be read from it -func (b *Builder) validateVMXTemplatePath() error { - f, err := os.Open(b.config.VMXTemplatePath) - if err != nil { - return err - } - defer f.Close() - - data, err := ioutil.ReadAll(f) - if err != nil { - return err - } - - return interpolate.Validate(string(data), &b.config.ctx) -} diff --git a/builder/vmware/iso/config.go b/builder/vmware/iso/config.go index e55a31dc2..99010ce26 100644 --- a/builder/vmware/iso/config.go +++ b/builder/vmware/iso/config.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "strings" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/common" @@ -218,8 +219,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { return c, warnings, nil } -// Validate the vmx_data option against the default vmx template to warn -// user if anything is being overridden. func (c *Config) checkForVMXTemplateAndVMXDataCollisions() string { if c.VMXTemplatePath != "" { return "" @@ -255,6 +254,7 @@ func (c *Config) checkForVMXTemplateAndVMXDataCollisions() string { return "" } +// Make sure custom vmx template exists and that data can be read from it func (c *Config) validateVMXTemplatePath() error { f, err := os.Open(c.VMXTemplatePath) if err != nil {