Do not error if cache/config directory not specified

Just use the default. Easier to use as an external library.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-11-20 13:52:53 +00:00
parent e3a7739f42
commit 6395e339b9
2 changed files with 12 additions and 2 deletions

View File

@ -142,7 +142,7 @@ func outputImage(image *Image, section string, prefix string, m Moby, idMap map[
// Build performs the actual build process // Build performs the actual build process
func Build(m Moby, w io.Writer, pull bool, tp string) error { func Build(m Moby, w io.Writer, pull bool, tp string) error {
if MobyDir == "" { if MobyDir == "" {
return fmt.Errorf("MobyDir for temporary storage not set") MobyDir = defaultMobyConfigDir()
} }
iw := tar.NewWriter(w) iw := tar.NewWriter(w)

View File

@ -1,6 +1,16 @@
package moby package moby
import (
"path/filepath"
)
var ( var (
// MobyDir is the location of the cache directory which should be set by the caller // MobyDir is the location of the cache directory, defaults to ~/.moby
MobyDir string MobyDir string
) )
func defaultMobyConfigDir() string {
mobyDefaultDir := ".moby"
home := homeDir()
return filepath.Join(home, mobyDefaultDir)
}