e0ef11a4c2
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 <tibor@docker.com>
28 lines
539 B
Go
28 lines
539 B
Go
package builder
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/docker/docker/pkg/archive"
|
|
"github.com/docker/docker/utils"
|
|
)
|
|
|
|
// MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
|
|
func MakeGitContext(gitURL string) (ModifiableContext, error) {
|
|
root, err := utils.GitClone(gitURL)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
c, err := archive.Tar(root, archive.Uncompressed)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
defer func() {
|
|
// TODO: print errors?
|
|
c.Close()
|
|
os.RemoveAll(root)
|
|
}()
|
|
return MakeTarSumContext(c)
|
|
}
|