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