2015-09-06 17:26:40 +00:00
|
|
|
package builder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/archive"
|
2015-12-14 10:17:51 +00:00
|
|
|
"github.com/docker/docker/pkg/gitutils"
|
2015-09-06 17:26:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
|
|
|
|
func MakeGitContext(gitURL string) (ModifiableContext, error) {
|
2015-12-14 10:17:51 +00:00
|
|
|
root, err := gitutils.Clone(gitURL)
|
2015-09-06 17:26:40 +00:00
|
|
|
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)
|
|
|
|
}
|