From e5a4257fa76abf6e55e70c9ef4aa3387f0398440 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Sun, 6 Sep 2015 13:26:40 -0400 Subject: [PATCH] Abstract builder and implement server-side dockerfile builder This patch creates interfaces in builder/ for building Docker images. It is a first step in a series of patches to remove the daemon dependency on builder and later allow a client-side Dockerfile builder as well as potential builder plugins. It is needed because we cannot remove the /build API endpoint, so we need to keep the server-side Dockerfile builder, but we also want to reuse the same Dockerfile parser and evaluator for both server-side and client-side. builder/dockerfile/ and api/server/builder.go contain implementations of those interfaces as a refactoring of the current code. Signed-off-by: Tibor Vass --- ioutils/temp_unix.go | 10 ++++++++++ ioutils/temp_windows.go | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ioutils/temp_unix.go create mode 100644 ioutils/temp_windows.go diff --git a/ioutils/temp_unix.go b/ioutils/temp_unix.go new file mode 100644 index 0000000..1539ad2 --- /dev/null +++ b/ioutils/temp_unix.go @@ -0,0 +1,10 @@ +// +build !windows + +package ioutils + +import "io/ioutil" + +// TempDir on Unix systems is equivalent to ioutil.TempDir. +func TempDir(dir, prefix string) (string, error) { + return ioutil.TempDir(dir, prefix) +} diff --git a/ioutils/temp_windows.go b/ioutils/temp_windows.go new file mode 100644 index 0000000..c258e5f --- /dev/null +++ b/ioutils/temp_windows.go @@ -0,0 +1,18 @@ +// +build windows + +package ioutils + +import ( + "io/ioutil" + + "github.com/docker/docker/pkg/longpath" +) + +// TempDir is the equivalent of ioutil.TempDir, except that the result is in Windows longpath format. +func TempDir(dir, prefix string) (string, error) { + tempDir, err := ioutil.TempDir(dir, prefix) + if err != nil { + return "", err + } + return longpath.AddPrefix(tempDir), nil +}