fix rebase conflicts
This commit is contained in:
parent
89184ae384
commit
3b413d2e5e
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue