Merge pull request #2835 from mitchellh/sethvargo/revert
Revert "Merge pull request #2807 from markpeek/markpeek-docker-tmpdir"
This commit is contained in:
commit
82a7f6ef97
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StepTempDir creates a temporary directory that we use in order to
|
// StepTempDir creates a temporary directory that we use in order to
|
||||||
|
@ -19,19 +18,7 @@ func (s *StepTempDir) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
ui.Say("Creating a temporary directory for sharing data...")
|
ui.Say("Creating a temporary directory for sharing data...")
|
||||||
// Create the docker temp files in the current working directory
|
td, err := ioutil.TempDir("", "packer-docker")
|
||||||
// to work around an issue when running with docker-machine
|
|
||||||
// using vm's needing access to shared folder content. This assumes
|
|
||||||
// the current working directory is mapped as a share folder.
|
|
||||||
// Allow TMPDIR to override this location.
|
|
||||||
path := ""
|
|
||||||
if tmpdir := os.Getenv("TMPDIR"); tmpdir == "" {
|
|
||||||
abspath, err := filepath.Abs(".")
|
|
||||||
if err == nil {
|
|
||||||
path = abspath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
td, err := ioutil.TempDir(path, "packer-docker")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error making temp dir: %s", err)
|
err := fmt.Errorf("Error making temp dir: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
|
@ -3,8 +3,6 @@ package docker
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,7 +10,7 @@ func TestStepTempDir_impl(t *testing.T) {
|
||||||
var _ multistep.Step = new(StepTempDir)
|
var _ multistep.Step = new(StepTempDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testStepTempDir_impl(t *testing.T) string {
|
func TestStepTempDir(t *testing.T) {
|
||||||
state := testState(t)
|
state := testState(t)
|
||||||
step := new(StepTempDir)
|
step := new(StepTempDir)
|
||||||
defer step.Cleanup(state)
|
defer step.Cleanup(state)
|
||||||
|
@ -43,36 +41,4 @@ func testStepTempDir_impl(t *testing.T) string {
|
||||||
if _, err := os.Stat(dir); err == nil {
|
if _, err := os.Stat(dir); err == nil {
|
||||||
t.Fatalf("dir should be gone")
|
t.Fatalf("dir should be gone")
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStepTempDir(t *testing.T) {
|
|
||||||
testStepTempDir_impl(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStepTempDir_notmpdir(t *testing.T) {
|
|
||||||
tempenv := "TMPDIR"
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
tempenv = "TMP"
|
|
||||||
}
|
|
||||||
// Verify empty TMPDIR maps to current working directory
|
|
||||||
oldenv := os.Getenv(tempenv)
|
|
||||||
os.Setenv(tempenv, "")
|
|
||||||
defer os.Setenv(tempenv, oldenv)
|
|
||||||
|
|
||||||
dir1 := testStepTempDir_impl(t)
|
|
||||||
|
|
||||||
// Now set TMPDIR to current directory
|
|
||||||
abspath, err := filepath.Abs(".")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("could not get current working directory")
|
|
||||||
}
|
|
||||||
os.Setenv(tempenv, abspath)
|
|
||||||
|
|
||||||
dir2 := testStepTempDir_impl(t)
|
|
||||||
|
|
||||||
if filepath.Dir(dir1) != filepath.Dir(dir2) {
|
|
||||||
t.Fatalf("temp base directories do not match: %s %s", filepath.Dir(dir1), filepath.Dir(dir2))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue