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