Merge branch 'master' of https://github.com/mitchellh/packer
This commit is contained in:
commit
b610e8005c
|
@ -52,10 +52,11 @@ func TestConfigPrepare_exportPath(t *testing.T) {
|
||||||
|
|
||||||
raw := testConfig()
|
raw := testConfig()
|
||||||
|
|
||||||
// No export path
|
// No export path. This is invalid. Previously this would not error during
|
||||||
|
// validation and as a result the failure would happen at build time.
|
||||||
delete(raw, "export_path")
|
delete(raw, "export_path")
|
||||||
_, warns, errs := NewConfig(raw)
|
_, warns, errs := NewConfig(raw)
|
||||||
testConfigOk(t, warns, errs)
|
testConfigErr(t, warns, errs)
|
||||||
|
|
||||||
// Good export path
|
// Good export path
|
||||||
raw["export_path"] = "good"
|
raw["export_path"] = "good"
|
||||||
|
@ -70,14 +71,39 @@ func TestConfigPrepare_exportPath(t *testing.T) {
|
||||||
|
|
||||||
func TestConfigPrepare_exportPathAndCommit(t *testing.T) {
|
func TestConfigPrepare_exportPathAndCommit(t *testing.T) {
|
||||||
raw := testConfig()
|
raw := testConfig()
|
||||||
raw["commit"] = true
|
|
||||||
|
|
||||||
// No export path
|
// Export but no commit (explicit default)
|
||||||
|
raw["commit"] = false
|
||||||
_, warns, errs := NewConfig(raw)
|
_, warns, errs := NewConfig(raw)
|
||||||
|
testConfigOk(t, warns, errs)
|
||||||
|
|
||||||
|
// Commit AND export specified (invalid)
|
||||||
|
raw["commit"] = true
|
||||||
|
_, warns, errs = NewConfig(raw)
|
||||||
testConfigErr(t, warns, errs)
|
testConfigErr(t, warns, errs)
|
||||||
|
|
||||||
// No commit
|
// Commit but no export
|
||||||
raw["commit"] = false
|
delete(raw, "export_path")
|
||||||
|
_, warns, errs = NewConfig(raw)
|
||||||
|
testConfigOk(t, warns, errs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigPrepare_exportDiscard(t *testing.T) {
|
||||||
|
raw := testConfig()
|
||||||
|
|
||||||
|
// Export but no discard (explicit default)
|
||||||
|
raw["discard"] = false
|
||||||
|
_, warns, errs := NewConfig(raw)
|
||||||
|
testConfigOk(t, warns, errs)
|
||||||
|
|
||||||
|
// Discard AND export (invalid)
|
||||||
|
raw["discard"] = true
|
||||||
|
_, warns, errs = NewConfig(raw)
|
||||||
|
testConfigErr(t, warns, errs)
|
||||||
|
|
||||||
|
// Discard but no export
|
||||||
|
raw["discard"] = true
|
||||||
|
delete(raw, "export_path")
|
||||||
_, warns, errs = NewConfig(raw)
|
_, warns, errs = NewConfig(raw)
|
||||||
testConfigOk(t, warns, errs)
|
testConfigOk(t, warns, errs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,13 +201,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
b.config.VNCPortMax = 6000
|
b.config.VNCPortMax = 6000
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.config.Format == "" {
|
if b.config.VMName == "" {
|
||||||
b.config.Format = "qcow2"
|
b.config.VMName = fmt.Sprintf("packer-%s", b.config.PackerBuildName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.config.VMName == "" {
|
if b.config.Format == "" {
|
||||||
b.config.VMName = fmt.Sprintf("packer-%s.%s",
|
b.config.Format = "qcow2"
|
||||||
b.config.PackerBuildName, b.config.Format)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.config.FloppyFiles == nil {
|
if b.config.FloppyFiles == nil {
|
||||||
|
|
Loading…
Reference in New Issue