host tests; refactor util functions to support testing

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett
2015-01-31 11:42:58 -05:00
parent 25b45ffc7d
commit dcf58cfc2d
7 changed files with 92 additions and 27 deletions

View File

@@ -7,15 +7,20 @@ import (
"runtime"
)
func GetHomeDir() string {
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
func GetBaseDir() string {
baseDir := os.Getenv("MACHINE_DIR")
if baseDir == "" {
if runtime.GOOS == "windows" {
baseDir = os.Getenv("USERPROFILE")
} else {
baseDir = os.Getenv("HOME")
}
}
return os.Getenv("HOME")
return baseDir
}
func GetDockerDir() string {
return filepath.Join(GetHomeDir(), ".docker")
return filepath.Join(GetBaseDir(), ".docker")
}
func GetMachineDir() string {