builder/vmware: mirror virtualbox output dir changes
This commit is contained in:
parent
3976a34d29
commit
d851898131
@ -2,7 +2,6 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/mitchellh/packer/common"
|
"github.com/mitchellh/packer/common"
|
||||||
"github.com/mitchellh/packer/template/interpolate"
|
"github.com/mitchellh/packer/template/interpolate"
|
||||||
@ -17,13 +16,5 @@ func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig
|
|||||||
c.OutputDir = fmt.Sprintf("output-%s", pc.PackerBuildName)
|
c.OutputDir = fmt.Sprintf("output-%s", pc.PackerBuildName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var errs []error
|
return nil
|
||||||
if !pc.PackerForce {
|
|
||||||
if _, err := os.Stat(c.OutputDir); err == nil {
|
|
||||||
errs = append(errs, fmt.Errorf(
|
|
||||||
"Output directory '%s' already exists. It must not exist.", c.OutputDir))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return errs
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/packer/common"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mitchellh/packer/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOutputConfigPrepare(t *testing.T) {
|
func TestOutputConfigPrepare(t *testing.T) {
|
||||||
@ -23,43 +22,3 @@ func TestOutputConfigPrepare(t *testing.T) {
|
|||||||
t.Fatal("should have output dir")
|
t.Fatal("should have output dir")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOutputConfigPrepare_exists(t *testing.T) {
|
|
||||||
td, err := ioutil.TempDir("", "packer")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(td)
|
|
||||||
|
|
||||||
c := new(OutputConfig)
|
|
||||||
c.OutputDir = td
|
|
||||||
|
|
||||||
pc := &common.PackerConfig{
|
|
||||||
PackerBuildName: "foo",
|
|
||||||
PackerForce: false,
|
|
||||||
}
|
|
||||||
errs := c.Prepare(testConfigTemplate(t), pc)
|
|
||||||
if len(errs) == 0 {
|
|
||||||
t.Fatal("should have errors")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOutputConfigPrepare_forceExists(t *testing.T) {
|
|
||||||
td, err := ioutil.TempDir("", "packer")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(td)
|
|
||||||
|
|
||||||
c := new(OutputConfig)
|
|
||||||
c.OutputDir = td
|
|
||||||
|
|
||||||
pc := &common.PackerConfig{
|
|
||||||
PackerBuildName: "foo",
|
|
||||||
PackerForce: true,
|
|
||||||
}
|
|
||||||
errs := c.Prepare(testConfigTemplate(t), pc)
|
|
||||||
if len(errs) > 0 {
|
|
||||||
t.Fatal("should not have errors")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -353,8 +353,8 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
|
|||||||
if len(warns) > 0 {
|
if len(warns) > 0 {
|
||||||
t.Fatalf("bad: %#v", warns)
|
t.Fatalf("bad: %#v", warns)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Fatal("should have error")
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with a good one
|
// Test with a good one
|
||||||
|
Loading…
x
Reference in New Issue
Block a user